genirq: Avoid NULL OOPS in irq handling
PATCH 1/1 genirq: Avoid NULL OOPS in irq handling
Some devices (e.g. serial port) setup irq handler at dev open and free it at dev close. So, sometimes there is no irqaction for a specific irq. But some buggy devices may send irqs at any time. This patch avoid the NULL OOPS when irqaction isn't registered.
--- kernel/irq/handle.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/irq/handle.c +4 -0
@@ -135,6 +135,9 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)irqreturn_t retval =IRQ_NONE ;unsigned int flags =0 , irq = desc->irq_data.irq; +if (!action) + goto out; + do { irqreturn_t res;
@@ -174,6 +177,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)add_interrupt_randomness (irq, flags); +out:if (!noirqdebug)note_interrupt (irq, desc, retval);return retval;
Signature · 1 line
1.7.7.3
Quoted 4 lines · Huacai Chen
Some devices (e.g. serial port) setup irq handler at dev open and free it at dev close. So, sometimes there is no irqaction for a specific irq. But some buggy devices may send irqs at any time. This patch avoid the NULL OOPS when irqaction isn't registered.
All callers except the real per cpu interrupts are checking whether there is a valid action before calling. And serial ports are not routed to real per cpu interrupts. Can you provide more detailed information about the problem you are trying to solve please?
Thanks,
tglx
Quoted 31 lines
Signed-off-by Huacai Chen <[email protected]>--- kernel/irq/handle.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)kernel/irq/handle.c +4
-0@@ -135,6 +135,9 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)irqreturn_t retval =IRQ_NONE ;unsigned int flags =0 , irq = desc->irq_data.irq; +if (!action) + goto out; + do { irqreturn_t res;@@ -174,6 +177,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)add_interrupt_randomness (irq, flags); +out:if (!noirqdebug)note_interrupt (irq, desc, retval);return retval;Signature · 1 line
1.7.7.3
I use a Loongson-3(MIPS-series CPU) machine, there is a serial port integrated in the CPU (but it iss buggy), and it use handle_percpu_irq() as the irq handler. Maybe I should move the checking into handle_percpu_irq()?
Huacai
Quoted 50 lines · Huacai Chen
Quoted 5 lines
Some devices (e.g. serial port) setup irq handler at dev open and free it at dev close. So, sometimes there is no irqaction for a specific irq. But some buggy devices may send irqs at any time. This patch avoid the NULL OOPS when irqaction isn't registered.
All callers except the real per cpu interrupts are checking whether there is a valid action before calling. And serial ports are not routed to real per cpu interrupts. Can you provide more detailed information about the problem you are trying to solve please?
Thanks,
tglx
Quoted 33 lines
Signed-off-by Huacai Chen <[email protected]>--- kernel/irq/handle.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)kernel/irq/handle.c +4
-0@@ -135,6 +135,9 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action) irqreturn_t retval = IRQ_NONE;unsigned int flags =0 , irq = desc->irq_data.irq; +if (!action) + goto out; + do { irqreturn_t res;@@ -174,6 +177,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)add_interrupt_randomness (irq ,flags ); +out:if (!noirqdebug)note_interrupt (irq, desc, retval);return retval;
--
1.7.7.3
Quoted 4 lines · 陈华才
I use a Loongson-3(MIPS-series CPU) machine, there is a serial port integrated in the CPU (but it iss buggy), and it use
handle_percpu_irq()as the irq handler. Maybe I should move the checking intohandle_percpu_irq()?
Why is a device interrupt using handle_percpu_irq()?
Thanks,
tglx
Quoted 8 lines · 陈华才
Quoted 5 lines
I use a Loongson-3(MIPS-series CPU) machine, there is a serial port integrated in the CPU (but it iss buggy), and it use
handle_percpu_irq()as the irq handler. Maybe I should move the checking intohandle_percpu_irq()?Why is a device interrupt using
handle_percpu_irq()?
Seems that IRQs directly deliverd to MIPS CPU (those without interrupt controller) are all handled by handle_percpu_irq().... I will try to overwrite the handler in arch-specific code and keep the code in kernel/ irq as is. Thanks.
Quoted 4 lines
Thanks,
tglx