summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorRicardo Cerqueira <v4l@cerqueira.org>2008-02-13 22:41:15 +0000
committerRicardo Cerqueira <v4l@cerqueira.org>2008-02-13 22:41:15 +0000
commit6494d36c801e81065cdfe9d1bf2b61b92e66111e (patch)
tree22a820291bdfea2e687164d5adf1c13f2e1d73e6 /linux/drivers
parent4890c6c64ffcaed9a31fc856b2935f8417f339e7 (diff)
downloadmediapointer-dvb-s2-6494d36c801e81065cdfe9d1bf2b61b92e66111e.tar.gz
mediapointer-dvb-s2-6494d36c801e81065cdfe9d1bf2b61b92e66111e.tar.bz2
cx88-mpeg: Fix race condition in variable access
From: Ricardo Cerqueira <v4l@cerqueira.org> There was a possible race condition in the increment/decrement of the active device references counter. Thanks to Trent Piepho (xyzzy@speakeasy.org) for bringing it up. Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org>
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/video/cx88/cx88-mpeg.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-mpeg.c b/linux/drivers/media/video/cx88/cx88-mpeg.c
index 399c3f1fc..1f641273c 100644
--- a/linux/drivers/media/video/cx88/cx88-mpeg.c
+++ b/linux/drivers/media/video/cx88/cx88-mpeg.c
@@ -673,8 +673,8 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
if (drv->advise_acquire)
{
- core->active_ref++;
mutex_lock(&drv->core->lock);
+ core->active_ref++;
if (core->active_type_id == CX88_BOARD_NONE) {
core->active_type_id = drv->type_id;
drv->advise_acquire(drv);
@@ -692,14 +692,14 @@ static int cx8802_request_release(struct cx8802_driver *drv)
{
struct cx88_core *core = drv->core;
+ mutex_lock(&drv->core->lock);
if (drv->advise_release && --core->active_ref == 0)
{
- mutex_lock(&drv->core->lock);
drv->advise_release(drv);
core->active_type_id = CX88_BOARD_NONE;
- mutex_unlock(&drv->core->lock);
mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO));
}
+ mutex_unlock(&drv->core->lock);
return 0;
}