]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.147/genirq-make-force-irq-threading-setup-more-robust.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.147 / genirq-make-force-irq-threading-setup-more-robust.patch
1 From d1f0301b3333eef5efbfa1fe0f0edbea01863d5d Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Fri, 3 Aug 2018 14:44:59 +0200
4 Subject: genirq: Make force irq threading setup more robust
5
6 From: Thomas Gleixner <tglx@linutronix.de>
7
8 commit d1f0301b3333eef5efbfa1fe0f0edbea01863d5d upstream.
9
10 The support of force threading interrupts which are set up with both a
11 primary and a threaded handler wreckaged the setup of regular requested
12 threaded interrupts (primary handler == NULL).
13
14 The reason is that it does not check whether the primary handler is set to
15 the default handler which wakes the handler thread. Instead it replaces the
16 thread handler with the primary handler as it would do with force threaded
17 interrupts which have been requested via request_irq(). So both the primary
18 and the thread handler become the same which then triggers the warnon that
19 the thread handler tries to wakeup a not configured secondary thread.
20
21 Fortunately this only happens when the driver omits the IRQF_ONESHOT flag
22 when requesting the threaded interrupt, which is normaly caught by the
23 sanity checks when force irq threading is disabled.
24
25 Fix it by skipping the force threading setup when a regular threaded
26 interrupt is requested. As a consequence the interrupt request which lacks
27 the IRQ_ONESHOT flag is rejected correctly instead of silently wreckaging
28 it.
29
30 Fixes: 2a1d3ab8986d ("genirq: Handle force threading of irqs with primary and thread handler")
31 Reported-by: Kurt Kanzenbach <kurt.kanzenbach@linutronix.de>
32 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
33 Tested-by: Kurt Kanzenbach <kurt.kanzenbach@linutronix.de>
34 Cc: stable@vger.kernel.org
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36
37 ---
38 kernel/irq/manage.c | 9 ++++++++-
39 1 file changed, 8 insertions(+), 1 deletion(-)
40
41 --- a/kernel/irq/manage.c
42 +++ b/kernel/irq/manage.c
43 @@ -1012,6 +1012,13 @@ static int irq_setup_forced_threading(st
44 if (new->flags & (IRQF_NO_THREAD | IRQF_PERCPU | IRQF_ONESHOT))
45 return 0;
46
47 + /*
48 + * No further action required for interrupts which are requested as
49 + * threaded interrupts already
50 + */
51 + if (new->handler == irq_default_primary_handler)
52 + return 0;
53 +
54 new->flags |= IRQF_ONESHOT;
55
56 /*
57 @@ -1019,7 +1026,7 @@ static int irq_setup_forced_threading(st
58 * thread handler. We force thread them as well by creating a
59 * secondary action.
60 */
61 - if (new->handler != irq_default_primary_handler && new->thread_fn) {
62 + if (new->handler && new->thread_fn) {
63 /* Allocate the secondary action */
64 new->secondary = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
65 if (!new->secondary)