diff mbox series

[2/3] media: dvb-usb: move kfree(d) to dvb_usb_device_exit

Message ID 20210621050729.3898275-2-mudongliangabcd@gmail.com
State New
Headers show
Series None | expand

Commit Message

Dongliang Mu June 21, 2021, 5:07 a.m. UTC
As d is allocated in dvb_usb_device_init, so move to the deallocation of
d from dvb_usb_exit to dvb_usb_device_exit

Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 drivers/media/usb/dvb-usb/dvb-usb-init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sean Young July 25, 2021, 1:47 p.m. UTC | #1
On Mon, Jun 21, 2021 at 01:07:27PM +0800, Dongliang Mu wrote:
> As d is allocated in dvb_usb_device_init, so move to the deallocation of

> d from dvb_usb_exit to dvb_usb_device_exit


There is nothing wrong with this patch, however I'm not sure what this
improves though. The code is just as good/messy as before, is it not?

Sean

> 

> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>

> ---

>  drivers/media/usb/dvb-usb/dvb-usb-init.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c

> index edc477cedaa9..21ad51be4820 100644

> --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c

> +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c

> @@ -147,7 +147,6 @@ static int dvb_usb_exit(struct dvb_usb_device *d)

>  		d->props.priv_destroy(d);

>  

>  	kfree(d->priv);

> -	kfree(d);

>  	return 0;

>  }

>  

> @@ -333,9 +332,10 @@ void dvb_usb_device_exit(struct usb_interface *intf)

>  	char name[40];

>  

>  	usb_set_intfdata(intf, NULL);

> -	if (d != NULL && d->desc != NULL) {

> +	if (d && d->desc) {

>  		strscpy(name, d->desc->name, sizeof(name));

>  		dvb_usb_exit(d);

> +		kfree(d);

>  	} else {

>  		strscpy(name, default_name, sizeof(name));

>  	}

> -- 

> 2.25.1
diff mbox series

Patch

diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c
index edc477cedaa9..21ad51be4820 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c
@@ -147,7 +147,6 @@  static int dvb_usb_exit(struct dvb_usb_device *d)
 		d->props.priv_destroy(d);
 
 	kfree(d->priv);
-	kfree(d);
 	return 0;
 }
 
@@ -333,9 +332,10 @@  void dvb_usb_device_exit(struct usb_interface *intf)
 	char name[40];
 
 	usb_set_intfdata(intf, NULL);
-	if (d != NULL && d->desc != NULL) {
+	if (d && d->desc) {
 		strscpy(name, d->desc->name, sizeof(name));
 		dvb_usb_exit(d);
+		kfree(d);
 	} else {
 		strscpy(name, default_name, sizeof(name));
 	}