* request for 4.14-stable: f9ffcb0a21e1 ("media: uvcvideo: Fix driver reference counting")
@ 2018-10-23 9:56 Sudip Mukherjee
2018-10-31 14:45 ` Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2018-10-23 9:56 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: stable, Philipp Zabel, Laurent Pinchart, Mauro Carvalho Chehab
[-- Attachment #1: Type: text/plain, Size: 136 bytes --]
Hi Greg,
This was not marked for stable but seems it should be in stable.
Please apply to your queue of 4.14-stable.
--
Regards
Sudip
[-- Attachment #2: 0001-media-uvcvideo-Fix-driver-reference-counting.patch --]
[-- Type: text/x-diff, Size: 2482 bytes --]
>From 58961baf4f29165ac293b11bd0e296e9d65e7c0b Mon Sep 17 00:00:00 2001
From: Philipp Zabel <philipp.zabel@gmail.com>
Date: Mon, 21 May 2018 06:24:58 -0400
Subject: [PATCH] media: uvcvideo: Fix driver reference counting
commit f9ffcb0a21e1fa8e64d09ed613d884e054ae8191 upstream
kref_init initializes the reference count to 1, not 0. This additional
reference is never released since the conversion to reference counters.
As a result, uvc_delete is not called anymore when UVC cameras are
disconnected.
Fix this by adding an additional kref_put in uvc_disconnect and in the
probe error path. This also allows to remove the temporary additional
reference in uvc_unregister_video.
Fixes: 9d15cd958c17 ("media: uvcvideo: Convert from using an atomic variable to a reference count")
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
drivers/media/usb/uvc/uvc_driver.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 6d22b22cb35b..064d88299adc 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1865,13 +1865,6 @@ static void uvc_unregister_video(struct uvc_device *dev)
{
struct uvc_streaming *stream;
- /* Unregistering all video devices might result in uvc_delete() being
- * called from inside the loop if there's no open file handle. To avoid
- * that, increment the refcount before iterating over the streams and
- * decrement it when done.
- */
- kref_get(&dev->ref);
-
list_for_each_entry(stream, &dev->streams, list) {
if (!video_is_registered(&stream->vdev))
continue;
@@ -1880,8 +1873,6 @@ static void uvc_unregister_video(struct uvc_device *dev)
uvc_debugfs_cleanup_stream(stream);
}
-
- kref_put(&dev->ref, uvc_delete);
}
static int uvc_register_video(struct uvc_device *dev,
@@ -2129,6 +2120,7 @@ static int uvc_probe(struct usb_interface *intf,
error:
uvc_unregister_video(dev);
+ kref_put(&dev->ref, uvc_delete);
return -ENODEV;
}
@@ -2146,6 +2138,7 @@ static void uvc_disconnect(struct usb_interface *intf)
return;
uvc_unregister_video(dev);
+ kref_put(&dev->ref, uvc_delete);
}
static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: request for 4.14-stable: f9ffcb0a21e1 ("media: uvcvideo: Fix driver reference counting")
2018-10-23 9:56 request for 4.14-stable: f9ffcb0a21e1 ("media: uvcvideo: Fix driver reference counting") Sudip Mukherjee
@ 2018-10-31 14:45 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2018-10-31 14:45 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: Greg Kroah-Hartman, stable, Philipp Zabel, Laurent Pinchart,
Mauro Carvalho Chehab
On Tue, Oct 23, 2018 at 10:56:27AM +0100, Sudip Mukherjee wrote:
>Hi Greg,
>
>This was not marked for stable but seems it should be in stable.
>Please apply to your queue of 4.14-stable.
Queued for 4.14.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-31 23:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-23 9:56 request for 4.14-stable: f9ffcb0a21e1 ("media: uvcvideo: Fix driver reference counting") Sudip Mukherjee
2018-10-31 14:45 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox