]> Git Repo - linux.git/commitdiff
irqchip/riscv-aplic: Prevent crash when MSI domain is missing
authorSamuel Holland <[email protected]>
Thu, 14 Nov 2024 20:01:30 +0000 (12:01 -0800)
committerThomas Gleixner <[email protected]>
Fri, 15 Nov 2024 23:45:37 +0000 (00:45 +0100)
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: ca8df97fe679 ("irqchip/riscv-aplic: Add support for MSI-mode")
Signed-off-by: Samuel Holland <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lore.kernel.org/all/[email protected]
drivers/irqchip/irq-riscv-aplic-main.c
drivers/irqchip/irq-riscv-aplic-msi.c

index 900e72541db9e59bd75905c4982263155e6df480..93e7c51f944abe4cb96fc7427c1f36ab7d2cbc4d 100644 (file)
@@ -207,7 +207,8 @@ static int aplic_probe(struct platform_device *pdev)
        else
                rc = aplic_direct_setup(dev, regs);
        if (rc)
-               dev_err(dev, "failed to setup APLIC in %s mode\n", msi_mode ? "MSI" : "direct");
+               dev_err_probe(dev, rc, "failed to setup APLIC in %s mode\n",
+                             msi_mode ? "MSI" : "direct");
 
 #ifdef CONFIG_ACPI
        if (!acpi_disabled)
index 945bff28265cdc9e5905f3ed285f0f6c8feecf07..fb8d1838609fb5177784e1bf440c4ccf0b96006f 100644 (file)
@@ -266,6 +266,9 @@ int aplic_msi_setup(struct device *dev, void __iomem *regs)
                        if (msi_domain)
                                dev_set_msi_domain(dev, msi_domain);
                }
+
+               if (!dev_get_msi_domain(dev))
+                       return -EPROBE_DEFER;
        }
 
        if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, &aplic_msi_template,
This page took 0.05676 seconds and 4 git commands to generate.