]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.17/genirq-deal-with-desc-set_type-changing-desc-chip.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.17 / genirq-deal-with-desc-set_type-changing-desc-chip.patch
1 From 4673247562e39a17e09440fa1400819522ccd446 Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Mon, 7 Jun 2010 17:53:51 +0200
4 Subject: genirq: Deal with desc->set_type() changing desc->chip
5
6 From: Thomas Gleixner <tglx@linutronix.de>
7
8 commit 4673247562e39a17e09440fa1400819522ccd446 upstream.
9
10 The set_type() function can change the chip implementation when the
11 trigger mode changes. That might result in using an non-initialized
12 irq chip when called from __setup_irq() or when called via
13 set_irq_type() on an already enabled irq.
14
15 The set_irq_type() function should not be called on an enabled irq,
16 but because we forgot to put a check into it, we have a bunch of users
17 which grew the habit of doing that and it never blew up as the
18 function is serialized via desc->lock against all users of desc->chip
19 and they never hit the non-initialized irq chip issue.
20
21 The easy fix for the __setup_irq() issue would be to move the
22 irq_chip_set_defaults(desc->chip) call after the trigger setting to
23 make sure that a chip change is covered.
24
25 But as we have already users, which do the type setting after
26 request_irq(), the safe fix for now is to call irq_chip_set_defaults()
27 from __irq_set_trigger() when desc->set_type() changed the irq chip.
28
29 It needs a deeper analysis whether we should refuse to change the chip
30 on an already enabled irq, but that'd be a large scale change to fix
31 all the existing users. So that's neither stable nor 2.6.35 material.
32
33 Reported-by: Esben Haabendal <eha@doredevelopment.dk>
34 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
35 Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
36 Cc: linuxppc-dev <linuxppc-dev@ozlabs.org>
37 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
38
39 ---
40 kernel/irq/manage.c | 3 +++
41 1 file changed, 3 insertions(+)
42
43 --- a/kernel/irq/manage.c
44 +++ b/kernel/irq/manage.c
45 @@ -436,6 +436,9 @@ int __irq_set_trigger(struct irq_desc *d
46 /* note that IRQF_TRIGGER_MASK == IRQ_TYPE_SENSE_MASK */
47 desc->status &= ~(IRQ_LEVEL | IRQ_TYPE_SENSE_MASK);
48 desc->status |= flags;
49 +
50 + if (chip != desc->chip)
51 + irq_chip_set_defaults(desc->chip);
52 }
53
54 return ret;