Skip to contentSkip to conversation

staging: r8188eu: os_dep: use kmemdup instead of kzalloc and memcpy

PATCH In review Saurav Girepunje 2 participants 4 messages Aug 28, 2021 – Sep 4, 2021 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: os_dep: use kmemdup instead of kzalloc and memcpy

Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c

---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/os_dep/ioctl_linux.c +1 -3
index 81d4255d1785..495fadd2b8c8 100644
@@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
 	}
 
 	if (ielen) {
-		buf = kzalloc(ielen, GFP_KERNEL);
+		buf = kmemdup(pie, ielen, GFP_KERNEL);
 		if (!buf) {
 			ret =  -ENOMEM;
 			goto exit;
 		}
 
-		memcpy(buf, pie, ielen);
-
 		/* dump */
 		{
 			int i;

--
2.32.0

maintainer
#1 lore raw
Quoted 28 lines · Saurav Girepunje

Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c

---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/os_dep/ioctl_linux.c +1 -4
index 81d4255d1785..495fadd2b8c8 100644
@@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
 	}
 
 	if (ielen) {
-		buf = kzalloc(ielen, GFP_KERNEL);
+		buf = kmemdup(pie, ielen, GFP_KERNEL);
 		if (!buf) {
 			ret =  -ENOMEM;
 			goto exit;
 		}
 
-		memcpy(buf, pie, ielen);
-
 		/* dump */
 		{
 			int i;
--
Quoted 3 lines

2.32.0

This patch never showed up on lore.kernel.org for some reason. Please resend and see if it was a mailing issue on your side...

thanks,

greg k-h

#2 lore raw
Quoted 36 lines · Greg KH
Quoted 28 lines · Saurav Girepunje

Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c

---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/os_dep/ioctl_linux.c +1 -4
index 81d4255d1785..495fadd2b8c8 100644
@@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
 	}
 
 	if (ielen) {
-		buf = kzalloc(ielen, GFP_KERNEL);
+		buf = kmemdup(pie, ielen, GFP_KERNEL);
 		if (!buf) {
 			ret =  -ENOMEM;
 			goto exit;
 		}
 
-		memcpy(buf, pie, ielen);
-
 		/* dump */
 		{
 			int i;
--
Quoted 3 lines

2.32.0

This patch never showed up on lore.kernel.org for some reason. Please resend and see if it was a mailing issue on your side...

Quoted 3 lines

thanks,

greg k-h

Ok, I will resend this patch.

Thanks,
Saurav Girepunje

#3 lore raw
Quoted 39 lines · SAURAV GIREPUNJE
Quoted 38 lines · Greg KH
Quoted 28 lines · Saurav Girepunje

Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c

---
  drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/os_dep/ioctl_linux.c +1 -4
index 81d4255d1785..495fadd2b8c8 100644
@@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
  	}
 
  	if (ielen) {
-		buf = kzalloc(ielen, GFP_KERNEL);
+		buf = kmemdup(pie, ielen, GFP_KERNEL);
  		if (!buf) {
  			ret =  -ENOMEM;
  			goto exit;
  		}
 
-		memcpy(buf, pie, ielen);
-
  		/* dump */
  		{
  			int i;
--
Quoted 3 lines

2.32.0

This patch never showed up on lore.kernel.org for some reason. Please resend and see if it was a mailing issue on your side...

thanks,

Quoted 8 lines
Quoted 1 line

greg k-h

Ok, I will resend this patch.

Thanks,
Saurav Girepunje

Hi Greg,

I have resend the patch, But the last patch also on lore.kernel.org
https://lore.kernel.org/all/YSp9z2%2FJmvHGhW5m@user/

Regards,
Saurav Girepunje