LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH linux-next] staging: r8188eu: Use kzalloc() instead of kmalloc()+memset()
@ 2021-09-16  2:16 CGEL
  2021-09-16 13:47 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: CGEL @ 2021-09-16  2:16 UTC (permalink / raw)
  To: Larry Finger
  Cc: Phillip Potter, Greg Kroah-Hartman, Michael Straube,
	Martin Kaiser, 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.

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 | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index 92b8f2c..9c257c4 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -463,11 +463,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) {
-- 
1.8.3.1



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

* Re: [PATCH linux-next] staging: r8188eu: Use kzalloc() instead of kmalloc()+memset()
  2021-09-16  2:16 [PATCH linux-next] staging: r8188eu: Use kzalloc() instead of kmalloc()+memset() CGEL
@ 2021-09-16 13:47 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-09-16 13:47 UTC (permalink / raw)
  To: CGEL
  Cc: Larry Finger, Phillip Potter, Greg Kroah-Hartman,
	Michael Straube, Martin Kaiser, linux-staging, linux-kernel,
	Changcheng Deng, Zeal Robot

On Thu, Sep 16, 2021 at 02:16:58AM +0000, CGEL wrote:
> From: Changcheng Deng <deng.changcheng@zte.com.cn>
> 
> This place can use kzalloc() directly instead of calling kmalloc() then
> memset(). Replace them.
> 
> 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 | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> index 92b8f2c..9c257c4 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -463,11 +463,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;

Missing error code as well.  It should be "ret = -ENOMEM;".

regards,
dan carpenter



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

end of thread, other threads:[~2021-09-16 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16  2:16 [PATCH linux-next] staging: r8188eu: Use kzalloc() instead of kmalloc()+memset() CGEL
2021-09-16 13:47 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).