crypto: qat - avoid memory corruption or undefined behaviour
authorTudor Ambarus <tudor-dan.ambarus@nxp.com>
Wed, 23 Mar 2016 15:06:39 +0000 (17:06 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 5 Apr 2016 12:35:52 +0000 (20:35 +0800)
memcopying to a (null pointer + offset) will result
in memory corruption or undefined behaviour.

Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_common/qat_asym_algs.c

index e5c0727d48767fb638cb52541601c0fd55c0471a..8dbbf08494366e9e7ff7ec4ac1ba56635190b1e0 100644 (file)
@@ -593,7 +593,7 @@ int qat_rsa_get_d(void *context, size_t hdrlen, unsigned char tag,
 
        ret = -ENOMEM;
        ctx->d = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_d, GFP_KERNEL);
-       if (!ctx->n)
+       if (!ctx->d)
                goto err;
 
        memcpy(ctx->d + (ctx->key_sz - vlen), ptr, vlen);