staging: r8188eu: use kzalloc instead of kmalloc and memset
PATCH 1/1 staging: r8188eu: use kzalloc instead of kmalloc and memset
Fix following coccicheck warning:
./drivers/staging/r8188eu/os_dep/ioctl_linux.c:422:10-17:
WARNING: kzalloc should be used for pwep, instead of kmalloc/memset
--- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/r8188eu/os_dep/ioctl_linux.c +1 -2
@@ -419,11 +419,10 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,if (wep_key_len >0 ) { wep_key_len = wep_key_len <=5 ?5 :13 ; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep =kmalloc (wep_total_len,GFP_KERNEL ); + pwep =kzalloc (wep_total_len,GFP_KERNEL );if (!pwep) goto exit; -memset (pwep,0 , wep_total_len); pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len;if (wep_key_len ==13 ) {
Signature · 1 line
2.20.1
Quoted 14 lines · Wan Jiabing
Fix following coccicheck warning:
./drivers/staging/r8188eu/os_dep/ioctl_linux.c:422:10-17:
WARNING: kzalloc should be used for pwep, instead of kmalloc/memsetSigned-off-by Wan Jiabing <[email protected]>--- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/staging/r8188eu/os_dep/ioctl_linux.c +0
-0
drivers/staging/r8188eu/os_dep/ioctl_linux.c static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, · line 424
Quoted 7 lines
drivers/staging/r8188eu/os_dep/ioctl_linux.c +1
-1@@ -419,11 +419,10 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,if (wep_key_len >0 ) { wep_key_len = wep_key_len <=5 ?5 :13 ; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep =kmalloc (wep_total_len,GFP_KERNEL ); + pwep =kzalloc (wep_total_len,GFP_KERNEL );if (!pwep) goto exit;
Not related to your patch, but this is missing an error code as well. It should be:
if (!pwep) {
ret = -ENOMEM;
goto exit;
}regards,
dan carpenter
Greg Kroah-Hartman
maintainerQuoted 8 lines · Wan Jiabing
Fix following coccicheck warning:
./drivers/staging/r8188eu/os_dep/ioctl_linux.c:422:10-17:
WARNING: kzalloc should be used for pwep, instead of kmalloc/memsetSigned-off-by Wan Jiabing <[email protected]>--- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Someone just sent this same patch before you did, sorry:
https://lore.kernel.org/r/20211012024624.GA1062447@embeddedor