Browse Source

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 <tudor-dan.ambarus@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Tudor Ambarus 8 years ago
parent
commit
7fcaf62a9f
1 changed files with 2 additions and 0 deletions
  1. 2 0
      drivers/crypto/caam/caampkc.c

+ 2 - 0
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)