cx88: hold device lock during sub-driver initialization
authorJonathan Nieder <jrnieder@gmail.com>
Sun, 1 May 2011 09:29:56 +0000 (06:29 -0300)
committerSteve Conklin <sconklin@canonical.com>
Fri, 15 Jul 2011 17:21:08 +0000 (12:21 -0500)
commit3db6328edd247d90fc17e7d44bc0e599b07b3e25
tree71340e2f48d5a74b7471491b0b16c1cec77994ec
parent4533f6347a2f9a11c3bfbbde54dd25100d6aee14
cx88: hold device lock during sub-driver initialization

BugLink: http://bugs.launchpad.net/bugs/793702

commit 1d6213ab995c61f7d1d81cf6cf876acf15d6e714 upstream.

cx8802_blackbird_probe makes a device node for the mpeg sub-device
before it has been added to dev->drvlist.  If the device is opened
during that time, the open succeeds but request_acquire cannot be
called, so the reference count remains zero.  Later, when the device
is closed, the reference count becomes negative --- uh oh.

Close the race by holding core->lock during probe and not releasing
until the device is in drvlist and initialization finished.
Previously the BKL prevented this race.

Reported-by: Andreas Huber <hobrom@gmx.at>
Tested-by: Andi Huber <hobrom@gmx.at>
Tested-by: Marlon de Boer <marlon@hyves.nl>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/media/video/cx88/cx88-blackbird.c
drivers/media/video/cx88/cx88-mpeg.c
drivers/media/video/cx88/cx88.h