mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Michael Buesch <mb@bu3sch.de>
Cc: philb@gnu.org, carsten@sol.wohnheim.uni-ulm.de, renau@acm.org,
	tim@cyberelk.demon.co.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] IEEE1284: Use del_timer_sync in parport_wait_event
Date: Tue, 2 Dec 2008 16:30:55 -0800	[thread overview]
Message-ID: <20081202163055.e80e0b81.akpm@linux-foundation.org> (raw)
In-Reply-To: <200811302120.49766.mb@bu3sch.de>

On Sun, 30 Nov 2008 21:20:49 +0100
Michael Buesch <mb@bu3sch.de> wrote:

> 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@bu3sch.de>
> 
> ---
> 
> 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.
> 

Yes, I agree.

> ===================================================================
> --- 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;

Please fix checkpatch errors when altering code.  This function is
already a mismash of correct and incorrect styles - we might as well
increase the correctness density.

What we really want in this function is down_interruptible_timeout(). 
afaict we have all the infrastructure in place to implement that, but
nobody has typed

static noinline int __sched
__down_interruptible_timeout(struct semaphore *sem, long jiffies)
{
	return __down_common(sem, TASK_INTERRUPTIBLE, jiffies);
}

and then tested it.

Or convert the whole thing to mutexes and write
mutex_lock_interruptible_timeout() :)


      reply	other threads:[~2008-12-03  0:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-30 20:20 Michael Buesch
2008-12-03  0:30 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081202163055.e80e0b81.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=carsten@sol.wohnheim.uni-ulm.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=philb@gnu.org \
    --cc=renau@acm.org \
    --cc=tim@cyberelk.demon.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome