Skip to contentSkip to conversation

s390/pkey: fix kzalloc-simple.cocci warnings

PATCH Applied Vasyl Gomonovych 2 participants 2 messages Oct 11, 2017 – Oct 13, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/pkey: fix kzalloc-simple.cocci warnings

drivers/s390/crypto/pkey_api.c:128:11-18: WARNING: kzalloc should be used for cprbmem, instead of kmalloc/memset

Use kzalloc rather than kmalloc followed by memset with 0

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

---
 drivers/s390/crypto/pkey_api.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/s390/crypto/pkey_api.c +1 -2
index f61fa47..8dda5bb 100644
@@ -125,10 +125,9 @@ static int alloc_and_prep_cprbmem(size_t paramblen,
 	 * allocate consecutive memory for request CPRB, request param
 	 * block, reply CPRB and reply param block
 	 */
-	cprbmem = kmalloc(2 * cprbplusparamblen, GFP_KERNEL);
+	cprbmem = kzalloc(2 * cprbplusparamblen, GFP_KERNEL);
 	if (!cprbmem)
 		return -ENOMEM;
-	memset(cprbmem, 0, 2 * cprbplusparamblen);
 
 	preqcblk = (struct CPRBX *) cprbmem;
 	prepcblk = (struct CPRBX *) (cprbmem + cprbplusparamblen);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 17 lines · Vasyl Gomonovych

drivers/s390/crypto/pkey_api.c:128:11-18: WARNING: kzalloc should be used for cprbmem, instead of kmalloc/memset

Use kzalloc rather than kmalloc followed by memset with 0

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

---
 drivers/s390/crypto/pkey_api.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/s390/crypto/pkey_api.c +0 -0
index f61fa47..8dda5bb 100644
@@ -125,10 +125,9 @@ static int alloc_and_prep_cprbmem(size_t paramblen,
 	 * allocate consecutive memory for request CPRB, request param

drivers/s390/crypto/pkey_api.c static int alloc_and_prep_cprbmem(size_t paramblen, · line 133

Quoted 10 lines
drivers/s390/crypto/pkey_api.c +1 -2
 	 * block, reply CPRB and reply param block
 	 */
-	cprbmem = kmalloc(2 * cprbplusparamblen, GFP_KERNEL);
+	cprbmem = kzalloc(2 * cprbplusparamblen, GFP_KERNEL);
 	if (!cprbmem)
 		return -ENOMEM;
-	memset(cprbmem, 0, 2 * cprbplusparamblen);
 
 	preqcblk = (struct CPRBX *) cprbmem;
 	prepcblk = (struct CPRBX *) (cprbmem + cprbplusparamblen);

applied, will be available with the next merge window. Thanks