[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210731161831.GA909851@pc>
Date: Sat, 31 Jul 2021 17:18:31 +0100
From: Salah Triki <salah.triki@...il.com>
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
gregkh@...uxfoundation.org
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2] usb: stkwebcam: update the reference count of the usb
device structure
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.
Signed-off-by: Salah Triki <salah.triki@...il.com>
---
Change since v1:
Modification of the description
drivers/media/usb/stkwebcam/stk-webcam.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index a45d464427c4..3b14679829ed 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -1309,7 +1309,7 @@ static int stk_camera_probe(struct usb_interface *interface,
init_waitqueue_head(&dev->wait_frame);
dev->first_init = 1; /* webcam LED management */
- dev->udev = udev;
+ dev->udev = usb_get_dev(udev);
dev->interface = interface;
usb_get_intf(interface);
@@ -1376,6 +1376,7 @@ static void stk_camera_disconnect(struct usb_interface *interface)
usb_set_intfdata(interface, NULL);
unset_present(dev);
+ usb_put_dev(interface_to_usbdev(interface));
wake_up_interruptible(&dev->wait_frame);
--
2.25.1
Powered by blists - more mailing lists