]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
crypto: bcm - add error check in the ahash_hmac_init function
authorChen Ridong <chenridong@huawei.com>
Mon, 4 Nov 2024 12:17:45 +0000 (12:17 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 15 Nov 2024 11:52:51 +0000 (19:52 +0800)
The ahash_init functions may return fails. The ahash_hmac_init should
not return ok when ahash_init returns error. For an example, ahash_init
will return -ENOMEM when allocation memory is error.

Fixes: 9d12ba86f818 ("crypto: brcm - Add Broadcom SPU driver")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/bcm/cipher.c

index 7540eb7cd3310d0b81ffeaaf6435684ba2bab1e2..9e6798efbfb769676b9026e168e246f6d5fb5071 100644 (file)
@@ -2415,6 +2415,7 @@ static int ahash_hmac_setkey(struct crypto_ahash *ahash, const u8 *key,
 
 static int ahash_hmac_init(struct ahash_request *req)
 {
+       int ret;
        struct iproc_reqctx_s *rctx = ahash_request_ctx(req);
        struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
        struct iproc_ctx_s *ctx = crypto_ahash_ctx(tfm);
@@ -2424,7 +2425,9 @@ static int ahash_hmac_init(struct ahash_request *req)
        flow_log("ahash_hmac_init()\n");
 
        /* init the context as a hash */
-       ahash_init(req);
+       ret = ahash_init(req);
+       if (ret)
+               return ret;
 
        if (!spu_no_incr_hash(ctx)) {
                /* SPU-M can do incr hashing but needs sw for outer HMAC */