]> www.infradead.org Git - linux.git/commitdiff
crypto: camm/qi - Use ERR_CAST() to return error-valued pointer
authorChen Yufan <chenyufan@vivo.com>
Fri, 6 Sep 2024 10:43:24 +0000 (18:43 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 13 Sep 2024 10:26:52 +0000 (18:26 +0800)
Instead of directly casting and returning (void *) pointer, use ERR_CAST
to explicitly return an error-valued pointer. This makes the error handling
more explicit and improves code clarity.

Signed-off-by: Chen Yufan <chenyufan@vivo.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg_qi.c

index 743ce50c14f2e076dbe222357b0611c3c2979552..13347dfecf7ac0ebc4783541dc7eef6755311850 100644 (file)
@@ -961,7 +961,7 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
 
        drv_ctx = get_drv_ctx(ctx, encrypt ? ENCRYPT : DECRYPT);
        if (IS_ERR(drv_ctx))
-               return (struct aead_edesc *)drv_ctx;
+               return ERR_CAST(drv_ctx);
 
        /* allocate space for base edesc and hw desc commands, link tables */
        edesc = qi_cache_alloc(flags);
@@ -1271,7 +1271,7 @@ static struct skcipher_edesc *skcipher_edesc_alloc(struct skcipher_request *req,
 
        drv_ctx = get_drv_ctx(ctx, encrypt ? ENCRYPT : DECRYPT);
        if (IS_ERR(drv_ctx))
-               return (struct skcipher_edesc *)drv_ctx;
+               return ERR_CAST(drv_ctx);
 
        src_nents = sg_nents_for_len(req->src, req->cryptlen);
        if (unlikely(src_nents < 0)) {