• Tejun Heo's avatar
    workqueue: convert BUG_ON()s in __queue_delayed_work() to WARN_ON_ONCE()s · 7b08c866
    Tejun Heo authored
    commit fc4b514f upstream.
    
    8852aac2 ("workqueue: mod_delayed_work_on() shouldn't queue timer on
    0 delay") unexpectedly uncovered a very nasty abuse of delayed_work in
    megaraid - it allocated work_struct, casted it to delayed_work and
    then pass that into queue_delayed_work().
    
    Previously, this was okay because 0 @delay short-circuited to
    queue_work() before doing anything with delayed_work.  8852aac2
    moved 0 @delay test into __queue_delayed_work() after sanity check on
    delayed_work making megaraid trigger BUG_ON().
    
    Although megaraid is already fixed by c1d390d8 ("megaraid: fix
    BUG_ON() from incorrect use of delayed work"), this patch converts
    BUG_ON()s in __queue_delayed_work() to WARN_ON_ONCE()s so that such
    abusers, if there are more, trigger warning but don't crash the
    machine.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Cc: Xiaotian Feng <xtfeng@gmail.com>
    [Shuah Khan: This change is back-ported from upstream change that
     converted BUG_ON()s in __queue_delayed_work() to WARN_ON_ONCE()s.]
    Tested on Stable Trees: 3.0.x, 3.4.x, 3.6.x
    Signed-off-by: default avatarShuah Khan <shuah.khan@hp.com>
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    7b08c866
workqueue.c 106 KB