diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2023-07-22 16:53:58 +0200 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2023-07-28 18:20:25 +0800 |
commit | 6df04505f3b285f3bcfe81cf0461339b0f4ed41d (patch) | |
tree | 97c1e28558da268de45166b20a48f1e065511d13 /drivers/crypto | |
parent | 81511798bdfb1a61f97569436789721aace942fb (diff) | |
download | linux-stable-6df04505f3b285f3bcfe81cf0461339b0f4ed41d.tar.gz linux-stable-6df04505f3b285f3bcfe81cf0461339b0f4ed41d.tar.bz2 linux-stable-6df04505f3b285f3bcfe81cf0461339b0f4ed41d.zip |
crypto: caam - Use struct_size()
Use struct_size() instead of hand-writing it, when allocating a structure
with a flex array.
This is less verbose, more robust and more informative.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/caam/caamhash.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 80deb003f0a5..9e5924e24f2e 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -708,9 +708,8 @@ static struct ahash_edesc *ahash_edesc_alloc(struct ahash_request *req, gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? GFP_KERNEL : GFP_ATOMIC; struct ahash_edesc *edesc; - unsigned int sg_size = sg_num * sizeof(struct sec4_sg_entry); - edesc = kzalloc(sizeof(*edesc) + sg_size, flags); + edesc = kzalloc(struct_size(edesc, sec4_sg, sg_num), flags); if (!edesc) { dev_err(ctx->jrdev, "could not allocate extended descriptor\n"); return NULL; |