Skip to contentSkip to conversation

staging: rtl8192e: Use kzalloc rather than kmalloc

PATCH New Thomas Meyer 1 participant 1 message Nov 8, 2011 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8192e: Use kzalloc rather than kmalloc

From: Thomas Meyer <[email protected]>

Use kzalloc rather than kmalloc followed by memset with 0

This considers some simple cases that are common and easy to validate Note in particular that there are no ...s in the rule, so all of the matched code has to be contiguous

The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/kzalloc-simple.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

---

drivers/staging/rtl8192e/rtllib_crypt.c 2011-11-08 09:40:09.789244618 +0100 renamed from drivers/staging/rtl8192e/rtllib_crypt.c 2011-11-07 19:38:11.773647045 +0100 +2 -4
diff -u -p a/drivers/staging/rtl8192e/rtllib_crypt.c b/drivers/staging/rtl8192e/rtllib_crypt.c
@@ -104,11 +104,10 @@ int rtllib_register_crypto_ops(struct rt
 	if (hcrypt == NULL)
 		return -1;
 
-	alg = kmalloc(sizeof(*alg), GFP_KERNEL);
+	alg = kzalloc(sizeof(*alg), GFP_KERNEL);
 	if (alg == NULL)
 		return -ENOMEM;
 
-	memset(alg, 0, sizeof(*alg));
 	alg->ops = ops;
 
 	spin_lock_irqsave(&hcrypt->lock, flags);
@@ -202,11 +201,10 @@ int __init rtllib_crypto_init(void)
 {
 	int ret = -ENOMEM;
 
-	hcrypt = kmalloc(sizeof(*hcrypt), GFP_KERNEL);
+	hcrypt = kzalloc(sizeof(*hcrypt), GFP_KERNEL);
 	if (!hcrypt)
 		goto out;
 
-	memset(hcrypt, 0, sizeof(*hcrypt));
 	INIT_LIST_HEAD(&hcrypt->algs);
 	spin_lock_init(&hcrypt->lock);