irqdomain: Add missing NULL pointer check in irq_domain_create_hierarchy()

The recent switch to per-domain locking caused a NULL dereference in
irq_domain_create_hierarchy(), as Xen code is calling
msi_create_irq_domain() with a NULL parent pointer.

Fix that by testing parent to be set before dereferencing it. For a
non-existing parent the irqdomain's root will stay to point to
itself.

Fixes: 9dbb8e3452 ("irqdomain: Switch to per-domain locking")
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20230223083800.31347-1-jgross@suse.com
This commit is contained in:
Juergen Gross 2023-02-23 09:38:00 +01:00 committed by Thomas Gleixner
parent 5931e4eb55
commit ad32ab9604
1 changed files with 2 additions and 1 deletions

View File

@ -1172,7 +1172,8 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
domain = __irq_domain_create(fwnode, 0, ~0, 0, ops, host_data);
if (domain) {
domain->root = parent->root;
if (parent)
domain->root = parent->root;
domain->parent = parent;
domain->flags |= flags;