aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2017-08-25 08:14:09 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-08-25 16:40:26 -0400
commit20c4d49c0f304f3f945bbd560b26afa98f75a0c4 (patch)
treefe4412f34fda31cb74dd9cfc696ee9c5d5c469c9
parentce8bdd6957202a38d67038e5ec940eed50f9f3eb (diff)
irqdomain: Prevent potential NULL pointer dereference in irq_domain_push_irq()
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() can return a NULL pointer, but the code dereferences the returned pointer before checking it. Move the NULL pointer check before the dereference. [ tglx: Rewrote changelog to be precise and conforming to the instructions in submitting-patches and added a Fixes tag. Sigh! ] Fixes: 495c38d3001f ("irqdomain: Add irq_domain_{push,pop}_irq() functions") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: David Daney <david.daney@cavium.com> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: kernel-janitors@vger.kernel.org Link: http://lkml.kernel.org/r/20170825121409.6rfv4vt6ztz2oqkt@mwanda
-rw-r--r--kernel/irq/irqdomain.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 1ff9912211e9..d62351714f3e 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1504,10 +1504,10 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg)
1504 if (WARN_ON(!irq_domain_is_hierarchy(domain))) 1504 if (WARN_ON(!irq_domain_is_hierarchy(domain)))
1505 return -EINVAL; 1505 return -EINVAL;
1506 1506
1507 if (domain->parent != root_irq_data->domain) 1507 if (!root_irq_data)
1508 return -EINVAL; 1508 return -EINVAL;
1509 1509
1510 if (!root_irq_data) 1510 if (domain->parent != root_irq_data->domain)
1511 return -EINVAL; 1511 return -EINVAL;
1512 1512
1513 child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL, 1513 child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL,