mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
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>
This commit is contained in:
parent
81511798bd
commit
6df04505f3
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user