public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uvc: fix race of open and suspend in error case
@ 2013-01-10 10:04 Oliver Neukum
  2013-01-10 10:48 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Oliver Neukum @ 2013-01-10 10:04 UTC (permalink / raw)
  To: linux-usb, laurent.pinchart, tom.leiming, linux-media; +Cc: Oliver Neukum

Ming Lei reported:
IMO, there is a minor fault in the error handling path of
uvc_status_start() inside uvc_v4l2_open(), and the 'users' count
should have been decreased before usb_autopm_put_interface().
In theory, the warning can be triggered when the device is
opened just between usb_autopm_put_interface() and
atomic_dec(&stream->dev->users).
The fix is trivial.

Signed-off-by:Oliver Neukum <oneukum@suse.de>
---
 drivers/media/usb/uvc/uvc_v4l2.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index f2ee8c6..74937b7 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -501,8 +501,8 @@ static int uvc_v4l2_open(struct file *file)
 	if (atomic_inc_return(&stream->dev->users) == 1) {
 		ret = uvc_status_start(stream->dev);
 		if (ret < 0) {
-			usb_autopm_put_interface(stream->dev->intf);
 			atomic_dec(&stream->dev->users);
+			usb_autopm_put_interface(stream->dev->intf);
 			kfree(handle);
 			return ret;
 		}
-- 
1.7.10.4


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

end of thread, other threads:[~2013-01-10 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10 10:04 [PATCH] uvc: fix race of open and suspend in error case Oliver Neukum
2013-01-10 10:48 ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox