linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb/usbtmc: Remove a redundant kref_put in usbtmc_disconnect
@ 2021-03-11 15:03 Lv Yunlong
  2021-03-12 14:30 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Lv Yunlong @ 2021-03-11 15:03 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, linux-kernel, Lv Yunlong

In the implementation of usbtmc_free_int(), it already calls
kref_put() to free the data as shown below. So, in
usbtmc_disconnect, call an extra kref_put() is redundant.

"""
static void usbtmc_free_int(struct usbtmc_device_data *data)
{
	if (!data->iin_ep_present || !data->iin_urb)
		return;
	usb_kill_urb(data->iin_urb);
	kfree(data->iin_buffer);
	data->iin_buffer = NULL;
	usb_free_urb(data->iin_urb);
	data->iin_urb = NULL;
	kref_put(&data->kref, usbtmc_delete);
}
"""

Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
 drivers/usb/class/usbtmc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 74d5a9c5238a..adcdd2df1949 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -2494,7 +2494,6 @@ static void usbtmc_disconnect(struct usb_interface *intf)
 	}
 	mutex_unlock(&data->io_mutex);
 	usbtmc_free_int(data);
-	kref_put(&data->kref, usbtmc_delete);
 }
 
 static void usbtmc_draw_down(struct usbtmc_file_data *file_data)
-- 
2.25.1



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

* Re: [PATCH] usb/usbtmc: Remove a redundant kref_put in usbtmc_disconnect
  2021-03-11 15:03 [PATCH] usb/usbtmc: Remove a redundant kref_put in usbtmc_disconnect Lv Yunlong
@ 2021-03-12 14:30 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-03-12 14:30 UTC (permalink / raw)
  To: Lv Yunlong; +Cc: linux-usb, linux-kernel

On Thu, Mar 11, 2021 at 07:03:54AM -0800, Lv Yunlong wrote:
> In the implementation of usbtmc_free_int(), it already calls
> kref_put() to free the data as shown below. So, in
> usbtmc_disconnect, call an extra kref_put() is redundant.
> 
> """
> static void usbtmc_free_int(struct usbtmc_device_data *data)
> {
> 	if (!data->iin_ep_present || !data->iin_urb)
> 		return;
> 	usb_kill_urb(data->iin_urb);
> 	kfree(data->iin_buffer);
> 	data->iin_buffer = NULL;
> 	usb_free_urb(data->iin_urb);
> 	data->iin_urb = NULL;
> 	kref_put(&data->kref, usbtmc_delete);
> }
> """
> 
> Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
> ---
>  drivers/usb/class/usbtmc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index 74d5a9c5238a..adcdd2df1949 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -2494,7 +2494,6 @@ static void usbtmc_disconnect(struct usb_interface *intf)
>  	}
>  	mutex_unlock(&data->io_mutex);
>  	usbtmc_free_int(data);
> -	kref_put(&data->kref, usbtmc_delete);

Did you test this change?

If not, please do so, I think the code is fine as-is.

thanks,

greg k-h

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

end of thread, other threads:[~2021-03-12 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 15:03 [PATCH] usb/usbtmc: Remove a redundant kref_put in usbtmc_disconnect Lv Yunlong
2021-03-12 14:30 ` Greg KH

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).