crypto: caam - Use struct_size()
[linux-2.6-microblaze.git] / drivers / crypto / caam / caamhash.c
index 80deb00..9e5924e 100644 (file)
@@ -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;