diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2013-01-04 06:33:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-07 17:48:25 -0500 |
commit | c0729eeefdcd76db338f635162bf0739fd2c5f6f (patch) | |
tree | 93325e4764bd7144631ff129b4e0f412f48d0d7f /drivers | |
parent | 34ffb33e09132401872fe79e95c30824ce194d23 (diff) |
staging: comedi: comedi_test: fix race when cancelling command
Éric Piel reported a kernel oops in the "comedi_test" module. It was a
NULL pointer dereference within `waveform_ai_interrupt()` (actually a
timer function) that sometimes occurred when a running asynchronous
command is cancelled (either by the `COMEDI_CANCEL` ioctl or by closing
the device file).
This seems to be a race between the caller of `waveform_ai_cancel()`
which on return from that function goes and tears down the running
command, and the timer function which uses the command. In particular,
`async->cmd.chanlist` gets freed (and the pointer set to NULL) by
`do_become_nonbusy()` in "comedi_fops.c" but a previously scheduled
`waveform_ai_interrupt()` timer function will dereference that pointer
regardless, leading to the oops.
Fix it by replacing the `del_timer()` call in `waveform_ai_cancel()`
with `del_timer_sync()`.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reported-by: Éric Piel <piel@delmic.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/drivers/comedi_test.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index fb3d09323ba1..01de996239f1 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c | |||
@@ -345,7 +345,7 @@ static int waveform_ai_cancel(struct comedi_device *dev, | |||
345 | struct waveform_private *devpriv = dev->private; | 345 | struct waveform_private *devpriv = dev->private; |
346 | 346 | ||
347 | devpriv->timer_running = 0; | 347 | devpriv->timer_running = 0; |
348 | del_timer(&devpriv->timer); | 348 | del_timer_sync(&devpriv->timer); |
349 | return 0; | 349 | return 0; |
350 | } | 350 | } |
351 | 351 | ||