From: Devin Heitmueller Date: Tue, 28 Apr 2009 17:35:27 +0000 (-0300) Subject: V4L/DVB (11784): cx88: Fix race condition between cx8800 startup and hald X-Git-Tag: firefly_0821_release~13887^2~53 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=06f837cadbcdedb45f0702cb57c99c404ae921e6;p=firefly-linux-kernel-4.4.55.git V4L/DVB (11784): cx88: Fix race condition between cx8800 startup and hald A power management fix to properly put the xc5000 into low power mode revealed a race condition where hald could detect the creation of the device file and connect to the device while the initial device configuration is still in progress. Lock the core structure so that video_release cannot be called and put the tuner to sleep in the middle of the initial call to cx88_set_tvnorm() in cx8800_initdev() Thanks to Michael Krufky for discovering the issue and providing an environment to test in. Cc: Michael Krufky Signed-off-by: Devin Heitmueller Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index b993d42fe73c..d6d6d13a6a6b 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c @@ -926,8 +926,10 @@ static int video_release(struct file *file) file->private_data = NULL; kfree(fh); + mutex_lock(&dev->core->lock); if(atomic_dec_and_test(&dev->core->users)) call_all(dev->core, tuner, s_standby); + mutex_unlock(&dev->core->lock); return 0; }