crypto: caam - fix operator precedence in shared descriptor allocation
authorKim Phillips <kim.phillips@freescale.com>
Thu, 26 May 2011 03:30:34 +0000 (13:30 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 29 Jun 2011 23:43:27 +0000 (07:43 +0800)
setkey allocates 16 bytes (CAAM_CMD_SZ *
DESC_AEAD_SHARED_TEXT_LEN) shy of what is needed to
store the shared descriptor, resulting in memory
corruption.  Fix this.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c

index d0e65d6ddc77caf5e860bae1d5fb92f4a25fb00e..676d957c22b0bc8e14bff79e1020845bdb6bbb1a 100644 (file)
@@ -238,9 +238,9 @@ static int build_sh_desc_ipsec(struct caam_ctx *ctx)
 
        /* build shared descriptor for this session */
        sh_desc = kmalloc(CAAM_CMD_SZ * DESC_AEAD_SHARED_TEXT_LEN +
-                         keys_fit_inline ?
-                         ctx->split_key_pad_len + ctx->enckeylen :
-                         CAAM_PTR_SZ * 2, GFP_DMA | GFP_KERNEL);
+                         (keys_fit_inline ?
+                          ctx->split_key_pad_len + ctx->enckeylen :
+                          CAAM_PTR_SZ * 2), GFP_DMA | GFP_KERNEL);
        if (!sh_desc) {
                dev_err(jrdev, "could not allocate shared descriptor\n");
                return -ENOMEM;