Skip to contentSkip to conversation

staging: rtl8723bs: replace kzalloc/memcpy with kmemdup

PATCH Superseded Lin YuChen 2 participants 2 messages Mar 9 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lin YuChen

author
#0 lore raw

PATCH v2 1/1 staging: rtl8723bs: replace kzalloc/memcpy with kmemdup

Replace the open-coded kzalloc and memcpy combination with kmemdup() to make the code more concise and idiomatic.

---
v2:
- Use real name in Signed-off-by line as requested by Ethan Tidmore.
- Fix a minor whitespace issue in the error return path.

 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2 -4
index 7cb0c6f22bf3..3db6417a7de1 100644
@@ -1430,14 +1430,12 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
 		goto exit;
 	}
 
-	buf = kzalloc(ielen, GFP_KERNEL);
+	buf = kmemdup(pie, ielen, GFP_KERNEL);
 	if (!buf) {
-		ret =  -ENOMEM;
+		ret = -ENOMEM;
 		goto exit;
 	}
 
-	memcpy(buf, pie, ielen);
-
 	if (ielen < RSN_HEADER_LEN) {
 		ret  = -1;
 		goto exit;
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 16 lines · Lin YuChen

Replace the open-coded kzalloc and memcpy combination with kmemdup() to make the code more concise and idiomatic.

---
v2:
- Use real name in Signed-off-by line as requested by Ethan Tidmore.
- Fix a minor whitespace issue in the error return path.

 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +0 -0
index 7cb0c6f22bf3..3db6417a7de1 100644

drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel · line 1435

Quoted 8 lines
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2 -2
@@ -1430,14 +1430,12 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
 		goto exit;
 	}
 
-	buf = kzalloc(ielen, GFP_KERNEL);
+	buf = kmemdup(pie, ielen, GFP_KERNEL);
 	if (!buf) {
-		ret =  -ENOMEM;
+		ret = -ENOMEM;

You also changed the spacing here, while normally ok, it's not good for a first patch. Please only do one logical-thing-per-patch.

thanks,

greg k-h