Skip to content

Commit

Permalink
irqdomain: Prevent potential NULL pointer dereference in irq_domain_p…
Browse files Browse the repository at this point in the history
…ush_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: 495c38d ("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
  • Loading branch information
Dan Carpenter authored and Thomas Gleixner committed Aug 25, 2017
1 parent ce8bdd6 commit 20c4d49
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/irq/irqdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1504,10 +1504,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,
Expand Down

0 comments on commit 20c4d49

Please sign in to comment.