diff mbox series

[2/2] crypto: caam - Remove messages related to memory allocation failure

Message ID b8859de12248852f661cb051ffad79166e8dfa47.1690037578.git.christophe.jaillet@wanadoo.fr
State Accepted
Commit 3de0152bf26ff0c5083ef831ba7676fc4c92e63a
Headers show
Series [1/2] crypto: caam - Use struct_size() | expand

Commit Message

Christophe JAILLET July 22, 2023, 2:53 p.m. UTC
On memory allocation failure, the function calling stack is already logged.
So there is no need to explicitly log an extra message.

Remove them, ans simplify some code accordingly.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/crypto/caam/caamhash.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Gaurav Jain July 26, 2023, 7:19 a.m. UTC | #1
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>

> -----Original Message-----
> From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Sent: Saturday, July 22, 2023 8:24 PM
> To: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta
> <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>; Herbert Xu
> <herbert@gondor.apana.org.au>; David S. Miller <davem@davemloft.net>
> Cc: linux-kernel@vger.kernel.org; kernel-janitors@vger.kernel.org; Christophe
> JAILLET <christophe.jaillet@wanadoo.fr>; linux-crypto@vger.kernel.org
> Subject: [EXT] [PATCH 2/2] crypto: caam - Remove messages related to memory
> allocation failure
> 
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report this
> email' button
> 
> 
> On memory allocation failure, the function calling stack is already logged.
> So there is no need to explicitly log an extra message.
> 
> Remove them, ans simplify some code accordingly.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/crypto/caam/caamhash.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
> index 9e5924e24f2e..641c3afd59ca 100644
> --- a/drivers/crypto/caam/caamhash.c
> +++ b/drivers/crypto/caam/caamhash.c
> @@ -368,10 +368,8 @@ static int hash_digest_key(struct caam_hash_ctx *ctx,
> u32 *keylen, u8 *key,
>         int ret;
> 
>         desc = kmalloc(CAAM_CMD_SZ * 8 + CAAM_PTR_SZ * 2, GFP_KERNEL);
> -       if (!desc) {
> -               dev_err(jrdev, "unable to allocate key input memory\n");
> +       if (!desc)
>                 return -ENOMEM;
> -       }
> 
>         init_job_desc(desc, 0);
> 
> @@ -702,18 +700,14 @@ static struct ahash_edesc *ahash_edesc_alloc(struct
> ahash_request *req,
>                                              int sg_num, u32 *sh_desc,
>                                              dma_addr_t sh_desc_dma)  {
> -       struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
> -       struct caam_hash_ctx *ctx = crypto_ahash_ctx_dma(ahash);
>         struct caam_hash_state *state = ahash_request_ctx_dma(req);
>         gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
>                        GFP_KERNEL : GFP_ATOMIC;
>         struct ahash_edesc *edesc;
> 
>         edesc = kzalloc(struct_size(edesc, sec4_sg, sg_num), flags);
> -       if (!edesc) {
> -               dev_err(ctx->jrdev, "could not allocate extended descriptor\n");
> +       if (!edesc)
>                 return NULL;
> -       }
> 
>         state->edesc = edesc;
> 
> @@ -1908,10 +1902,8 @@ caam_hash_alloc(struct caam_hash_template
> *template,
>         struct crypto_alg *alg;
> 
>         t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
> -       if (!t_alg) {
> -               pr_err("failed to allocate t_alg\n");
> +       if (!t_alg)
>                 return ERR_PTR(-ENOMEM);
> -       }
> 
>         t_alg->ahash_alg = template->template_ahash;
>         halg = &t_alg->ahash_alg;
> --
> 2.34.1
diff mbox series

Patch

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index 9e5924e24f2e..641c3afd59ca 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -368,10 +368,8 @@  static int hash_digest_key(struct caam_hash_ctx *ctx, u32 *keylen, u8 *key,
 	int ret;
 
 	desc = kmalloc(CAAM_CMD_SZ * 8 + CAAM_PTR_SZ * 2, GFP_KERNEL);
-	if (!desc) {
-		dev_err(jrdev, "unable to allocate key input memory\n");
+	if (!desc)
 		return -ENOMEM;
-	}
 
 	init_job_desc(desc, 0);
 
@@ -702,18 +700,14 @@  static struct ahash_edesc *ahash_edesc_alloc(struct ahash_request *req,
 					     int sg_num, u32 *sh_desc,
 					     dma_addr_t sh_desc_dma)
 {
-	struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
-	struct caam_hash_ctx *ctx = crypto_ahash_ctx_dma(ahash);
 	struct caam_hash_state *state = ahash_request_ctx_dma(req);
 	gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
 		       GFP_KERNEL : GFP_ATOMIC;
 	struct ahash_edesc *edesc;
 
 	edesc = kzalloc(struct_size(edesc, sec4_sg, sg_num), flags);
-	if (!edesc) {
-		dev_err(ctx->jrdev, "could not allocate extended descriptor\n");
+	if (!edesc)
 		return NULL;
-	}
 
 	state->edesc = edesc;
 
@@ -1908,10 +1902,8 @@  caam_hash_alloc(struct caam_hash_template *template,
 	struct crypto_alg *alg;
 
 	t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
-	if (!t_alg) {
-		pr_err("failed to allocate t_alg\n");
+	if (!t_alg)
 		return ERR_PTR(-ENOMEM);
-	}
 
 	t_alg->ahash_alg = template->template_ahash;
 	halg = &t_alg->ahash_alg;