]> git.baikalelectronics.ru Git - kernel.git/commit
genirq: Fix reference leaks on irq affinity notifiers
authorEdward Cree <ecree@solarflare.com>
Fri, 13 Mar 2020 20:33:07 +0000 (20:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Apr 2020 09:02:04 +0000 (11:02 +0200)
commit964835eafbc22266dcc59b3c67985036b115ceea
treec6372e15d53f375c4170590d457841d7f59117d6
parent0004225973ac3534e14031de6c70713084c9cf0d
genirq: Fix reference leaks on irq affinity notifiers

commit 24daaf1bb8a4c80dc5c7637d1aae3eabee94bf4c upstream.

The handling of notify->work did not properly maintain notify->kref in two
 cases:
1) where the work was already scheduled, another irq_set_affinity_locked()
   would get the ref and (no-op-ly) schedule the work.  Thus when
   irq_affinity_notify() ran, it would drop the original ref but not the
   additional one.
2) when cancelling the (old) work in irq_set_affinity_notifier(), if there
   was outstanding work a ref had been got for it but was never put.
Fix both by checking the return values of the work handling functions
 (schedule_work() for (1) and cancel_work_sync() for (2)) and put the
 extra ref if the return value indicates preexisting work.

Fixes: 9ab6a14112fb ("genirq: Add IRQ affinity notifiers")
Fixes: 3acf0dd45a54 ("genirq: Prevent use-after-free and work list corruption")
Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ben Hutchings <ben@decadent.org.uk>
Link: https://lkml.kernel.org/r/24f5983f-2ab5-e83a-44ee-a45b5f9300f5@solarflare.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/irq/manage.c