[PATCH] IEEE1284: Use del_timer_sync in parport_wait_event



Use del_timer_sync() instead of del_timer() to make sure
the timer won't be running when we return from parport_wait_event(),
because this would crash due to destruction of timer_list.

Signed-off-by: Michael Buesch <mb@xxxxxxxxx>

---

This is completely untested and just based on a code review.
Just think about the following sequence of events:
add_timer.
down_interruptible is interrupted by a signal.
We enter the timer callback handler on another CPU.
del_timer, but the timer callback is still running.
Return from parport_wait_even, which destroys the automatic variable "timer"
while the callback is running on another CPU.

Index: linux-2.6/drivers/parport/ieee1284.c
===================================================================
--- linux-2.6.orig/drivers/parport/ieee1284.c 2008-10-24 21:08:12.000000000 +0200
+++ linux-2.6/drivers/parport/ieee1284.c 2008-11-30 21:09:25.000000000 +0100
@@ -84,7 +84,7 @@ int parport_wait_event (struct parport *

add_timer (&timer);
ret = down_interruptible (&port->physport->ieee1284.irq);
- if (!del_timer (&timer) && !ret)
+ if (!del_timer_sync (&timer) && !ret)
/* Timed out. */
ret = 1;


--
Greetings Michael.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH] IEEE1284: Use del_timer_sync in parport_wait_event
    ... We enter the timer callback handler on another CPU. ... increase the correctness density. ...
    (Linux-Kernel)
  • Re: Timed event - problem
    ... is the timer callback in a different thread than the main prog ... equivalent to using a polling loop and defeats the purpose of using a timer. ... And can a timer callback be called while we are still in a different timer ... I believe a timer callback function is just a function. ...
    (comp.unix.programmer)
  • Re: Thread Pooling when using SoapService & SoapClient
    ... > coming from the message receive timeout engine which is not transport ... > is creating and destroying a thread to handle the timer callback. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Problem with TimerCallback in.NET Compact Framework
    ... > In my application, I want to use timer callback,so that after a specified ... > time interval I'm able to do some logging operation continuously. ... > into the file stops and the timer no longer seems to be working. ... > Why is the timercallback not getting executed when I open any other ...
    (microsoft.public.dotnet.framework.compactframework)
  • Problems using System.Threading.Timer
    ... two Timer objects which control uptime of my apps. ... notify my apps to suspend and one is used to notify them to resume. ... The timer callback was invoked as expected... ...
    (microsoft.public.dotnet.csharp.general)