All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] genirq: Check irq_data_get_irq_chip() return value before use
@ 2020-05-07 15:07 Marek Vasut
  2020-05-07 17:30 ` Thomas Gleixner
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2020-05-07 15:07 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Marek Vasut, Marc Zyngier, Linus Walleij, Stephen Boyd, Thomas Gleixner

The irq_data_get_irq_chip() can return NULL. If the kernel accesses
chip->irq_get_irqchip_state without checking whether chip is valid,
we get a crash. Fix this by checking whether chip is not NULL before
using it.

Fixes: 1b7047edfcfb ("genirq: Allow the irqchip state of an IRQ to be save/restored")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
To: linux-arm-kernel@lists.infradead.org
---
NOTE: I don't know whether this is a correct fix. Maybe the
      irq_data_get_irq_chip() should never return NULL, and
      I have some other issue?
---
 kernel/irq/manage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index fe40c658f86f..509128ab21ea 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -2663,7 +2663,7 @@ int __irq_get_irqchip_state(struct irq_data *data, enum irqchip_irq_state which,
 
 	do {
 		chip = irq_data_get_irq_chip(data);
-		if (chip->irq_get_irqchip_state)
+		if (chip && chip->irq_get_irqchip_state)
 			break;
 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
 		data = data->parent_data;
@@ -2740,7 +2740,7 @@ int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
 
 	do {
 		chip = irq_data_get_irq_chip(data);
-		if (chip->irq_set_irqchip_state)
+		if (chip && chip->irq_set_irqchip_state)
 			break;
 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
 		data = data->parent_data;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-05-14 12:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 15:07 [PATCH] [RFC] genirq: Check irq_data_get_irq_chip() return value before use Marek Vasut
2020-05-07 17:30 ` Thomas Gleixner
2020-05-07 18:29   ` Marek Vasut
2020-05-07 21:51     ` Thomas Gleixner
2020-05-10 14:49       ` Marek Vasut
2020-05-13 20:49         ` Thomas Gleixner
2020-05-14  0:26           ` Marek Vasut
2020-05-14 12:16         ` Alexandre Torgue

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.