From: Tudor Ambarus Date: Wed, 23 Mar 2016 15:06:39 +0000 (+0200) Subject: crypto: qat - avoid memory corruption or undefined behaviour X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=aa8b6dd4b06bab62ec7f8972f9e66782dbc23d60;p=linux-beck.git crypto: qat - avoid memory corruption or undefined behaviour memcopying to a (null pointer + offset) will result in memory corruption or undefined behaviour. Signed-off-by: Tudor Ambarus Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c index e5c0727d4876..8dbbf0849436 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -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);