cx88: hold device lock during sub-driver initialization
commit80e0c7a68e493495c9006824dc7d476ab2ff3776
authorJonathan Nieder <jrnieder@gmail.com>
Sun, 1 May 2011 09:29:56 +0000 (1 06:29 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 3 Jun 2011 01:34:29 +0000 (3 10:34 +0900)
treed59ffc61e7d03b4c3895ad0332d40377f1e19bf4
parentd47b389e7b2de4086cbf1d811d6803245c3798fc
cx88: hold device lock during sub-driver initialization

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>
drivers/media/video/cx88/cx88-blackbird.c
drivers/media/video/cx88/cx88-mpeg.c
drivers/media/video/cx88/cx88.h