comedi_test: fix race when cancelling command
authorIan Abbott <abbotti@mev.co.uk>
Fri, 1 Feb 2013 14:03:23 +0000 (14:03 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Fri, 1 Feb 2013 14:03:23 +0000 (14:03 +0000)
In waveform_ai_cancel(), replace the call to del_timer() with
del_timer_sync() to avoid a race condition between the timer routine
which may already be running on another CPU and the caller of the cancel
routine which is about to free various bits used by the timer routine
(such as async->cmd.chanlist).

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
comedi/drivers/comedi_test.c

index 8321dc4e57e2633f5f0eb519cd08c3aea840cab9..6607fda11f7b8a032fa16331457a42dd1e0b76d0 100644 (file)
@@ -431,7 +431,7 @@ static int waveform_ai_cmd(comedi_device * dev, comedi_subdevice * s)
 static int waveform_ai_cancel(comedi_device * dev, comedi_subdevice * s)
 {
        devpriv->timer_running = 0;
 static int waveform_ai_cancel(comedi_device * dev, comedi_subdevice * s)
 {
        devpriv->timer_running = 0;
-       del_timer(&devpriv->timer);
+       del_timer_sync(&devpriv->timer);
        return 0;
 }
 
        return 0;
 }