* [PATCH] media: stkwebcam: Use usb_get_dev() for the reference count of udev
@ 2021-08-02 6:41 Cai Huoqing
2021-08-02 8:47 ` Cai,Huoqing
0 siblings, 1 reply; 3+ messages in thread
From: Cai Huoqing @ 2021-08-02 6:41 UTC (permalink / raw)
To: mchehab, hverkuil-cisco, paskripkin; +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/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 0e231e576dc3..b54a23c6842e 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -1234,6 +1234,7 @@ static void stk_v4l_dev_release(struct video_device *vd)
if (dev->sio_bufs != NULL || dev->isobufs != NULL)
pr_err("We are leaking memory\n");
usb_put_intf(dev->interface);
+ usb_put_dev(dev->udev);
}
static const struct video_device stk_v4l_data = {
@@ -1309,7 +1310,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);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] media: stkwebcam: Use usb_get_dev() for the reference count of udev
2021-08-02 6:41 [PATCH] media: stkwebcam: Use usb_get_dev() for the reference count of udev Cai Huoqing
@ 2021-08-02 8:47 ` Cai,Huoqing
0 siblings, 0 replies; 3+ messages in thread
From: Cai,Huoqing @ 2021-08-02 8:47 UTC (permalink / raw)
To: mchehab, hverkuil-cisco, paskripkin, salah.triki; +Cc: linux-media
Hello, Salah
I have read your patch
https://lore.kernel.org/patchwork/patch/1466782/
so I try to fix the same issue in stkwebcam:
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:42
> To: mchehab@kernel.org; hverkuil-cisco@xs4all.nl; paskripkin@gmail.com
> Cc: linux-media@vger.kernel.org; Cai,Huoqing <caihuoqing@baidu.com>
> Subject: [PATCH] media: stkwebcam: 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/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 0e231e576dc3..b54a23c6842e 100644
> --- a/drivers/media/usb/stkwebcam/stk-webcam.c
> +++ b/drivers/media/usb/stkwebcam/stk-webcam.c
> @@ -1234,6 +1234,7 @@ static void stk_v4l_dev_release(struct video_device
> *vd)
> if (dev->sio_bufs != NULL || dev->isobufs != NULL)
> pr_err("We are leaking memory\n");
> usb_put_intf(dev->interface);
> + usb_put_dev(dev->udev);
> }
>
> static const struct video_device stk_v4l_data = { @@ -1309,7 +1310,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);
>
> --
> 2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] media: stkwebcam: Use usb_get_dev() for the reference count of udev
@ 2021-08-02 6:58 Cai Huoqing
0 siblings, 0 replies; 3+ messages in thread
From: Cai Huoqing @ 2021-08-02 6:58 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/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 0e231e576dc3..b54a23c6842e 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -1234,6 +1234,7 @@ static void stk_v4l_dev_release(struct video_device *vd)
if (dev->sio_bufs != NULL || dev->isobufs != NULL)
pr_err("We are leaking memory\n");
usb_put_intf(dev->interface);
+ usb_put_dev(dev->udev);
}
static const struct video_device stk_v4l_data = {
@@ -1309,7 +1310,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);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-02 8:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 6:41 [PATCH] media: stkwebcam: Use usb_get_dev() for the reference count of udev Cai Huoqing
2021-08-02 8:47 ` Cai,Huoqing
2021-08-02 6:58 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.