From: Herbert Xu Date: Fri, 21 Nov 2025 05:54:20 +0000 (+0800) Subject: crypto: ahash - Zero positive err value in ahash_update_finish X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ebbdf6466b30e3b37f3b360826efd21f0633fb9e;p=thirdparty%2Flinux.git crypto: ahash - Zero positive err value in ahash_update_finish The partial block length returned by a block-only driver should not be passed up to the caller since ahash itself deals with the partial block data. Set err to zero in ahash_update_finish if it was positive. Reported-by: T Pratham Tested-by: T Pratham Fixes: 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API") Signed-off-by: Herbert Xu --- diff --git a/crypto/ahash.c b/crypto/ahash.c index 819b484a1a003..66492ae75fcfb 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -423,7 +423,11 @@ static int ahash_update_finish(struct ahash_request *req, int err) req->nbytes += nonzero - blen; - blen = err < 0 ? 0 : err + nonzero; + blen = 0; + if (err >= 0) { + blen = err + nonzero; + err = 0; + } if (ahash_request_isvirt(req)) memcpy(buf, req->svirt + req->nbytes - blen, blen); else