mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] irqdomain: Prevent Oops in irq_domain_push_irq()
@ 2017-08-25 12:14 Dan Carpenter
  2017-08-25 16:09 ` David Daney
  2017-08-25 20:43 ` [tip:irq/core] irqdomain: Prevent potential NULL pointer dereference " tip-bot for Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-08-25 12:14 UTC (permalink / raw)
  To: Marc Zyngier, David Daney; +Cc: Thomas Gleixner, linux-kernel, kernel-janitors

This code generates a Smatch warning:

	kernel/irq/irqdomain.c:1511 irq_domain_push_irq()
	warn: variable dereferenced before check 'root_irq_data' (see line 1508)

irq_get_irq_data() does sometimes return NULL pointers so this seems
like a real bug.  Let's fix this bug by moving the check for NULL
earlier.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Redo changelog.
v3: Redo changelog again.  Make it imperative.

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index b9c688944429..e84b7056bb08 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1505,10 +1505,10 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg)
 	if (WARN_ON(!irq_domain_is_hierarchy(domain)))
 		return -EINVAL;
 
-	if (domain->parent != root_irq_data->domain)
+	if (!root_irq_data)
 		return -EINVAL;
 
-	if (!root_irq_data)
+	if (domain->parent != root_irq_data->domain)
 		return -EINVAL;
 
 	child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL,

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

end of thread, other threads:[~2017-08-25 20:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 12:14 [PATCH v3] irqdomain: Prevent Oops in irq_domain_push_irq() Dan Carpenter
2017-08-25 16:09 ` David Daney
2017-08-25 20:43 ` [tip:irq/core] irqdomain: Prevent potential NULL pointer dereference " tip-bot for Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome