2021-08-28 18:26:20

by Saurav Girepunje

[permalink] [raw]
Subject: [PATCH] staging: r8188eu: os_dep: use kmemdup instead of kzalloc and memcpy

Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c

Signed-off-by: Saurav Girepunje <[email protected]>
---
drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index 81d4255d1785..495fadd2b8c8 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
}

if (ielen) {
- buf = kzalloc(ielen, GFP_KERNEL);
+ buf = kmemdup(pie, ielen, GFP_KERNEL);
if (!buf) {
ret = -ENOMEM;
goto exit;
}

- memcpy(buf, pie, ielen);
-
/* dump */
{
int i;
--
2.32.0


2021-09-02 09:23:26

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] staging: r8188eu: os_dep: use kmemdup instead of kzalloc and memcpy

On Sat, Aug 28, 2021 at 11:47:51PM +0530, Saurav Girepunje wrote:
> Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c
>
> Signed-off-by: Saurav Girepunje <[email protected]>
> ---
> drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> index 81d4255d1785..495fadd2b8c8 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
> }
>
> if (ielen) {
> - buf = kzalloc(ielen, GFP_KERNEL);
> + buf = kmemdup(pie, ielen, GFP_KERNEL);
> if (!buf) {
> ret = -ENOMEM;
> goto exit;
> }
>
> - memcpy(buf, pie, ielen);
> -
> /* dump */
> {
> int i;
> --
> 2.32.0
>
>

This patch never showed up on lore.kernel.org for some reason. Please
resend and see if it was a mailing issue on your side...

thanks,

greg k-h

2021-09-03 19:31:12

by Saurav Girepunje

[permalink] [raw]
Subject: Re: [PATCH] staging: r8188eu: os_dep: use kmemdup instead of kzalloc and memcpy

On 02 Sep 2021 11:20, Greg KH wrote:
> On Sat, Aug 28, 2021 at 11:47:51PM +0530, Saurav Girepunje wrote:
> > Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c
> >
> > Signed-off-by: Saurav Girepunje <[email protected]>
> > ---
> > drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > index 81d4255d1785..495fadd2b8c8 100644
> > --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > @@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
> > }
> >
> > if (ielen) {
> > - buf = kzalloc(ielen, GFP_KERNEL);
> > + buf = kmemdup(pie, ielen, GFP_KERNEL);
> > if (!buf) {
> > ret = -ENOMEM;
> > goto exit;
> > }
> >
> > - memcpy(buf, pie, ielen);
> > -
> > /* dump */
> > {
> > int i;
> > --
> > 2.32.0
> >
> >
>
> This patch never showed up on lore.kernel.org for some reason. Please
> resend and see if it was a mailing issue on your side...
>
> thanks,
>
> greg k-h


Ok, I will resend this patch.

Thanks,
Saurav Girepunje

2021-09-04 04:53:52

by Saurav Girepunje

[permalink] [raw]
Subject: Re: [PATCH] staging: r8188eu: os_dep: use kmemdup instead of kzalloc and memcpy



On 03/09/21 11:18 pm, SAURAV GIREPUNJE wrote:
> On 02 Sep 2021 11:20, Greg KH wrote:
>> On Sat, Aug 28, 2021 at 11:47:51PM +0530, Saurav Girepunje wrote:
>>> Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c
>>>
>>> Signed-off-by: Saurav Girepunje <[email protected]>
>>> ---
>>> drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +---
>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
>>> index 81d4255d1785..495fadd2b8c8 100644
>>> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
>>> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
>>> @@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
>>> }
>>>
>>> if (ielen) {
>>> - buf = kzalloc(ielen, GFP_KERNEL);
>>> + buf = kmemdup(pie, ielen, GFP_KERNEL);
>>> if (!buf) {
>>> ret = -ENOMEM;
>>> goto exit;
>>> }
>>>
>>> - memcpy(buf, pie, ielen);
>>> -
>>> /* dump */
>>> {
>>> int i;
>>> --
>>> 2.32.0
>>>
>>>
>>
>> This patch never showed up on lore.kernel.org for some reason. Please
>> resend and see if it was a mailing issue on your side...
>>
>> thanks,
>>
>> greg k-h
>
>
> Ok, I will resend this patch.
>
> Thanks,
> Saurav Girepunje
>

Hi Greg,

I have resend the patch, But the last patch also on lore.kernel.org
https://lore.kernel.org/all/YSp9z2%2FJmvHGhW5m@user/

Regards,
Saurav Girepunje