[PATCH] driver: r8188eu: remove NULL check before vfree

Dongliang Mu posted 1 patch 3 years, 10 months ago
There is a newer version of this series
drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] driver: r8188eu: remove NULL check before vfree
Posted by Dongliang Mu 3 years, 10 months ago
From: mudongliang <mudongliangabcd@gmail.com>

vfree can handle NULL pointer as its argument.
According to coccinelle isnullfree check, remove NULL check
before vfree operation.

Signed-off-by: mudongliang <mudongliangabcd@gmail.com>
---
 drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
index 68869c5daeff..bd1c8b4b5c4b 100644
--- a/drivers/staging/r8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
@@ -372,8 +372,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 free_adapter:
 	if (pnetdev)
 		rtw_free_netdev(pnetdev);
-	else if (padapter)
-		vfree(padapter);
+	vfree(padapter);
 
 	return NULL;
 }
-- 
2.35.1
Re: [PATCH] driver: r8188eu: remove NULL check before vfree
Posted by Greg Kroah-Hartman 3 years, 10 months ago
On Tue, Jun 14, 2022 at 05:03:30PM +0800, Dongliang Mu wrote:
> From: mudongliang <mudongliangabcd@gmail.com>
> 
> vfree can handle NULL pointer as its argument.
> According to coccinelle isnullfree check, remove NULL check
> before vfree operation.
> 
> Signed-off-by: mudongliang <mudongliangabcd@gmail.com>
> ---
>  drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
> index 68869c5daeff..bd1c8b4b5c4b 100644
> --- a/drivers/staging/r8188eu/os_dep/usb_intf.c
> +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
> @@ -372,8 +372,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
>  free_adapter:
>  	if (pnetdev)
>  		rtw_free_netdev(pnetdev);
> -	else if (padapter)
> -		vfree(padapter);
> +	vfree(padapter);

You changed the logic of this code here, please be more careful in the
future.

Also, you need to use your real name for the signed-off-by and From:
line.

thanks,

greg k-h
Re: [PATCH] driver: r8188eu: remove NULL check before vfree
Posted by Dongliang Mu 3 years, 10 months ago
On Tue, Jun 14, 2022 at 5:18 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Tue, Jun 14, 2022 at 05:03:30PM +0800, Dongliang Mu wrote:
> > From: mudongliang <mudongliangabcd@gmail.com>
> >
> > vfree can handle NULL pointer as its argument.
> > According to coccinelle isnullfree check, remove NULL check
> > before vfree operation.
> >
> > Signed-off-by: mudongliang <mudongliangabcd@gmail.com>
> > ---
> >  drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
> > index 68869c5daeff..bd1c8b4b5c4b 100644
> > --- a/drivers/staging/r8188eu/os_dep/usb_intf.c
> > +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
> > @@ -372,8 +372,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
> >  free_adapter:
> >       if (pnetdev)
> >               rtw_free_netdev(pnetdev);
> > -     else if (padapter)
> > -             vfree(padapter);
> > +     vfree(padapter);
>
> You changed the logic of this code here, please be more careful in the
> future.

Oh yes, I will move vfree into the else branch. Sorry for the mistake.

>
> Also, you need to use your real name for the signed-off-by and From:
> line.

Sure.

>
> thanks,
>
> greg k-h