mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb/usbtmc: Remove a redundant kref_put in usbtmc_disconnect
Date: Fri, 12 Mar 2021 15:30:37 +0100	[thread overview]
Message-ID: <YEt7DR4/7/ZLpUZA@kroah.com> (raw)
In-Reply-To: <20210311150354.8723-1-lyl2019@mail.ustc.edu.cn>

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

      reply	other threads:[~2021-03-12 14:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 15:03 Lv Yunlong
2021-03-12 14:30 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YEt7DR4/7/ZLpUZA@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lyl2019@mail.ustc.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®