[PATCH] staging: rtl8188eu: fix kzalloc-simple.cocci warnings

kbuild test robot lkp at intel.com
Tue Nov 28 08:00:56 UTC 2017


drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:3379:36-43: WARNING: kzalloc should be used for pwep, instead of kmalloc/memset


 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

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

Fixes: f1ac2c75e0c6 ("staging: rtl8188eu: Fix private WEXT IOCTL calls")
CC: Ishraq Ibne Ashraf <ishraq.i.ashraf at gmail.com>
Signed-off-by: Fengguang Wu <fengguang.wu at intel.com>
---

 ioctl_linux.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -3376,14 +3376,13 @@ static int rtw_set_encryption_pvt(struct
 			wep_key_len = wep_key_len <= 5 ? 5 : 13;
 			wep_total_len = wep_key_len + offsetof(struct ndis_802_11_wep, KeyMaterial);
 
-			pwep = (struct ndis_802_11_wep *)kmalloc(wep_total_len, GFP_KERNEL);
+			pwep = kzalloc(wep_total_len, GFP_KERNEL);
 			if (!pwep) {
 				DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n");
 				ret = -ENOMEM;
 				goto err_free_param;
 			}
 
-			memset(pwep, 0, wep_total_len);
 			pwep->KeyLength = wep_key_len;
 			pwep->Length = wep_total_len;
 		}


More information about the devel mailing list