Skip to content

Commit 1f181d1

Browse files
SiFiveHollandKAGA-KOKO
authored andcommitted
irqchip/riscv-aplic: Prevent crash when MSI domain is missing
If the APLIC driver is probed before the IMSIC driver, the parent MSI domain will be missing, which causes a NULL pointer dereference in msi_create_device_irq_domain(). Avoid this by deferring probe until the parent MSI domain is available. Use dev_err_probe() to avoid printing an error message when returning -EPROBE_DEFER. Fixes: ca8df97 ("irqchip/riscv-aplic: Add support for MSI-mode") Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20241114200133.3069460-1-samuel.holland@sifive.com
1 parent f9ed1f7 commit 1f181d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/irqchip/irq-riscv-aplic-main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ static int aplic_probe(struct platform_device *pdev)
207207
else
208208
rc = aplic_direct_setup(dev, regs);
209209
if (rc)
210-
dev_err(dev, "failed to setup APLIC in %s mode\n", msi_mode ? "MSI" : "direct");
210+
dev_err_probe(dev, rc, "failed to setup APLIC in %s mode\n",
211+
msi_mode ? "MSI" : "direct");
211212

212213
#ifdef CONFIG_ACPI
213214
if (!acpi_disabled)

drivers/irqchip/irq-riscv-aplic-msi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ int aplic_msi_setup(struct device *dev, void __iomem *regs)
266266
if (msi_domain)
267267
dev_set_msi_domain(dev, msi_domain);
268268
}
269+
270+
if (!dev_get_msi_domain(dev))
271+
return -EPROBE_DEFER;
269272
}
270273

271274
if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, &aplic_msi_template,

0 commit comments

Comments
 (0)