public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] staging: r8188eu: Use kzalloc() instead of kmalloc()+memset()
@ 2021-09-18  3:51 cgel.zte
  2021-09-18  6:29 ` Dan Carpenter
  2021-09-18  6:51 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: cgel.zte @ 2021-09-18  3:51 UTC (permalink / raw)
  To: Larry.Finger, dan.carpenter
  Cc: phil, gregkh, straube.linux, fmdefrancesco, martin, linux-staging,
	linux-kernel, Changcheng Deng, Zeal Robot

From: Changcheng Deng <deng.changcheng@zte.com.cn>

This place can use kzalloc() directly instead of calling kmalloc() then
memset(). Replace them.
At the same time,error code that is "ret = -ENOMEM;" should be added
here.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index ac218da94ce5..2fb34964f8c8 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -463,11 +463,12 @@ 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);
-			if (!pwep)
+			pwep = kzalloc(wep_total_len, GFP_KERNEL);
+			if (!pwep) {
+				ret = -ENOMEM;
 				goto exit;
+			}
 
-			memset(pwep, 0, wep_total_len);
 			pwep->KeyLength = wep_key_len;
 			pwep->Length = wep_total_len;
 			if (wep_key_len == 13) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-18  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-18  3:51 [PATCH V2] staging: r8188eu: Use kzalloc() instead of kmalloc()+memset() cgel.zte
2021-09-18  6:29 ` Dan Carpenter
2021-09-18  6:51 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox