[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210918035141.237455-1-deng.changcheng@zte.com.cn>
Date: Sat, 18 Sep 2021 03:51:41 +0000
From: cgel.zte@...il.com
To: Larry.Finger@...inger.net, dan.carpenter@...cle.com
Cc: phil@...lpotter.co.uk, gregkh@...uxfoundation.org,
straube.linux@...il.com, fmdefrancesco@...il.com, martin@...ser.cx,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
Changcheng Deng <deng.changcheng@....com.cn>,
Zeal Robot <zealci@....com.cn>
Subject: [PATCH V2] staging: r8188eu: Use kzalloc() instead of kmalloc()+memset()
From: Changcheng Deng <deng.changcheng@....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@....com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@....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
Powered by blists - more mailing lists