All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cai,Huoqing" <caihuoqing@baidu.com>
To: "mchehab@kernel.org" <mchehab@kernel.org>,
	"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
	"sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
	"gustavoars@kernel.org" <gustavoars@kernel.org>,
	"salah.triki@gmail.com" <salah.triki@gmail.com>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>
Subject: RE: [PATCH] media: smsusb: Use usb_get_dev() for the reference count of udev
Date: Mon, 2 Aug 2021 08:50:04 +0000	[thread overview]
Message-ID: <5c1d01a6a19c409091b224d3aea34d89@baidu.com> (raw)
In-Reply-To: <20210802065924.1163-1-caihuoqing@baidu.com>

Hello, Salah
the same
may I add "Reported-by: Salah Triki <salah.triki@gmail.com>"
ask for your comfirmation
if not, I will remove it.

> -----Original Message-----
> From: Cai,Huoqing <caihuoqing@baidu.com>
> Sent: 2021年8月2日 14:59
> To: mchehab@kernel.org; hverkuil-cisco@xs4all.nl; sakari.ailus@linux.intel.com;
> gustavoars@kernel.org
> Cc: linux-media@vger.kernel.org; Cai,Huoqing <caihuoqing@baidu.com>
> Subject: [PATCH] media: smsusb: Use usb_get_dev() for the reference count of
> udev
> 
> Use usb_get_dev() to increment the reference count of the usb device structure
> in order to avoid releasing the structure while it is still in use. And use
> usb_put_dev() to decrement the reference count and thus, when it will be equal
> to 0 the structure will be released.
> 
> Reported-by: Salah Triki <salah.triki@gmail.com>
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
> ---
>  drivers/media/usb/siano/smsusb.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/siano/smsusb.c
> b/drivers/media/usb/siano/smsusb.c
> index df4c5dcba39c..86e0a25f8dba 100644
> --- a/drivers/media/usb/siano/smsusb.c
> +++ b/drivers/media/usb/siano/smsusb.c
> @@ -351,6 +351,7 @@ static void smsusb_term_device(struct usb_interface
> *intf)
>  	}
> 
>  	usb_set_intfdata(intf, NULL);
> +	usb_put_dev(dev->udev);
>  }
> 
>  static void *siano_media_device_register(struct smsusb_device_t *dev, @@ -
> 398,7 +399,7 @@ static int smsusb_init_device(struct usb_interface *intf, int
> board_id)
> 
>  	memset(&params, 0, sizeof(params));
>  	usb_set_intfdata(intf, dev);
> -	dev->udev = interface_to_usbdev(intf);
> +	dev->udev = usb_get_dev(interface_to_usbdev(intf));
>  	dev->state = SMSUSB_DISCONNECTED;
> 
>  	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
> --
> 2.25.1


      reply	other threads:[~2021-08-02  8:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02  6:59 [PATCH] media: smsusb: Use usb_get_dev() for the reference count of udev Cai Huoqing
2021-08-02  8:50 ` Cai,Huoqing [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=5c1d01a6a19c409091b224d3aea34d89@baidu.com \
    --to=caihuoqing@baidu.com \
    --cc=gustavoars@kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=salah.triki@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.