Skip to content

Commit

Permalink
crypto: inside-secure - fix queued len computation
Browse files Browse the repository at this point in the history
This patch fixes the queued len computation, which could theoretically
be wrong if req->len[1] - req->processed[1] > 1. Be future-proof here,
and fix it.

Fixes: b460edb ("crypto: inside-secure - sha512 support")
Signed-off-by: Antoine Tenart <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
atenart authored and herbertx committed Jun 6, 2019
1 parent b926213 commit ccd65a2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/crypto/inside-secure/safexcel_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ struct safexcel_ahash_req {

static inline u64 safexcel_queued_len(struct safexcel_ahash_req *req)
{
if (req->len[1] > req->processed[1])
return 0xffffffff - (req->len[0] - req->processed[0]);
u64 len, processed;

return req->len[0] - req->processed[0];
len = (0xffffffff * req->len[1]) + req->len[0];
processed = (0xffffffff * req->processed[1]) + req->processed[0];

return len - processed;
}

static void safexcel_hash_token(struct safexcel_command_desc *cdesc,
Expand Down

0 comments on commit ccd65a2

Please sign in to comment.