All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: smsusb: Use usb_get_dev() for the reference count of udev
@ 2021-08-02  6:59 Cai Huoqing
  2021-08-02  8:50 ` Cai,Huoqing
  0 siblings, 1 reply; 2+ messages in thread
From: Cai Huoqing @ 2021-08-02  6:59 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, sakari.ailus, gustavoars
  Cc: linux-media, Cai Huoqing

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


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

end of thread, other threads:[~2021-08-02  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.