upstream: [media] uvcvideo: Fix open/close race condition
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 26 Apr 2013 01:28:51 +0000 (22:28 -0300)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 02:48:07 +0000 (11:48 +0900)
commitc0b97866de547c75e9f1927dd060f315005bd243
tree76eb4c1dc2542c84ab6836c58ade896768ed7476
parent5acc0505ac74e9c375faf8f161f8758b202de9c2
upstream: [media] uvcvideo: Fix open/close race condition

Maintaining the users count using an atomic variable makes sure that
access to the counter won't be racy, but doesn't serialize access to the
operations protected by the counter. This creates a race condition that
could result in the status URB being submitted multiple times.
Use a mutex to protect the users count and serialize access to the
status start and stop operations.

Reported-by: Shawn Nematbakhsh <shawnn@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/usb/uvc/uvc_driver.c
drivers/media/usb/uvc/uvc_status.c
drivers/media/usb/uvc/uvc_v4l2.c
drivers/media/usb/uvc/uvcvideo.h