LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: use kzalloc instead of kmalloc and memset
@ 2021-10-13 7:01 Wan Jiabing
2021-10-13 9:42 ` Dan Carpenter
2021-10-13 12:29 ` Greg Kroah-Hartman
0 siblings, 2 replies; 3+ messages in thread
From: Wan Jiabing @ 2021-10-13 7:01 UTC (permalink / raw)
To: Larry Finger, Phillip Potter, Greg Kroah-Hartman,
Michael Straube, Martin Kaiser, linux-staging, linux-kernel
Cc: kael_w, Wan Jiabing
Fix following coccicheck warning:
./drivers/staging/r8188eu/os_dep/ioctl_linux.c:422:10-17:
WARNING: kzalloc should be used for pwep, instead of kmalloc/memset
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
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 0201f6fbeb25..51f46696a593 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -419,11 +419,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) {
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: r8188eu: use kzalloc instead of kmalloc and memset
2021-10-13 7:01 [PATCH] staging: r8188eu: use kzalloc instead of kmalloc and memset Wan Jiabing
@ 2021-10-13 9:42 ` Dan Carpenter
2021-10-13 12:29 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-10-13 9:42 UTC (permalink / raw)
To: Wan Jiabing
Cc: Larry Finger, Phillip Potter, Greg Kroah-Hartman,
Michael Straube, Martin Kaiser, linux-staging, linux-kernel,
kael_w
On Wed, Oct 13, 2021 at 03:01:28AM -0400, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/staging/r8188eu/os_dep/ioctl_linux.c:422:10-17:
> WARNING: kzalloc should be used for pwep, instead of kmalloc/memset
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
> 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 0201f6fbeb25..51f46696a593 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -419,11 +419,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;
Not related to your patch, but this is missing an error code as well.
It should be:
if (!pwep) {
ret = -ENOMEM;
goto exit;
}
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: r8188eu: use kzalloc instead of kmalloc and memset
2021-10-13 7:01 [PATCH] staging: r8188eu: use kzalloc instead of kmalloc and memset Wan Jiabing
2021-10-13 9:42 ` Dan Carpenter
@ 2021-10-13 12:29 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-13 12:29 UTC (permalink / raw)
To: Wan Jiabing
Cc: Larry Finger, Phillip Potter, Michael Straube, Martin Kaiser,
linux-staging, linux-kernel, kael_w
On Wed, Oct 13, 2021 at 03:01:28AM -0400, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/staging/r8188eu/os_dep/ioctl_linux.c:422:10-17:
> WARNING: kzalloc should be used for pwep, instead of kmalloc/memset
>
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
> drivers/staging/r8188eu/os_dep/ioctl_linux.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
Someone just sent this same patch before you did, sorry:
https://lore.kernel.org/r/20211012024624.GA1062447@embeddedor
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-13 12:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 7:01 [PATCH] staging: r8188eu: use kzalloc instead of kmalloc and memset Wan Jiabing
2021-10-13 9:42 ` Dan Carpenter
2021-10-13 12:29 ` Greg Kroah-Hartman
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).