From 7fcaf62a9f6348bcdc8d2816f93f64cf7f3f87fc Mon Sep 17 00:00:00 2001 From: Tudor Ambarus Date: Tue, 25 Apr 2017 16:26:36 +0300 Subject: [PATCH] crypto: caam - avoid kzalloc(0) in caam_read_raw_data MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- drivers/crypto/caam/caampkc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index 49cbdcb..999ba18 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) -- 2.7.4