Re: [PATCH] cancel_rearming_delayed_work infinite loop fix

From: Herbert Xu
Date: Tue Jul 11 2006 - 06:12:12 EST


Michael Buesch <mb@xxxxxxxxx> wrote:
> cancel_rearming_delayed_work{queue} is broken, because it is
> possible to enter an infinite loop if:
> We call the function on a work that is currently not executing or pending.

Why are you calling it on a work that was never scheduled? Sounds like
a bug to me.

> void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
> struct work_struct *work)
> {
> - while (!cancel_delayed_work(work))
> + do {
> + cancel_delayed_work(work);
> flush_workqueue(wq);
> + } while (test_bit(0, &work->pending));

This is broken. If the work just starts running before your test_bit
you'd exit without cancelling it properly.

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
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/