From: Tudor Ambarus Date: Tue, 25 Apr 2017 13:26:36 +0000 (+0300) Subject: crypto: caam - avoid kzalloc(0) in caam_read_raw_data X-Git-Tag: v4.13-rc1~158^2~135 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fcaf62a9f6348bcdc8d2816f93f64cf7f3f87fc;p=thirdparty%2Fkernel%2Flinux.git crypto: caam - avoid kzalloc(0) in caam_read_raw_data The function returns NULL if buf is composed only of zeros. Signed-off-by: Tudor Ambarus Signed-off-by: Horia Geantă Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index 49cbdcba78830..999ba18495b0f 100644 --- a/drivers/crypto/caam/caampkc.c +++ b/drivers/crypto/caam/caampkc.c @@ -374,6 +374,8 @@ static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes) buf++; (*nbytes)--; } + if (!*nbytes) + return NULL; val = kzalloc(*nbytes, GFP_DMA | GFP_KERNEL); if (!val)