[PATCH] misc: hi6421v600-irq: Release IRQ mappings and domain on teardown

From: Guangshuo Li

Date: Sat Nov 28 2026 - 04:48:11 EST


A mapping or IRQ request failure leaves the domain and earlier mappings
registered. They also outlive the PMIC interrupt data on removal. Add
a managed cleanup before creating the first mapping, so the parent
handler is freed before the mappings are disposed of.

This issue was found by our static analysis tool under development.

Fixes: 4524ac56cdca ("staging: mfd: add a PMIC driver for HiSilicon 6421 SPMI version")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/misc/hi6421v600-irq.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/misc/hi6421v600-irq.c b/drivers/misc/hi6421v600-irq.c
index 7d2eb7ed7698..5b9d08b057f9 100644
--- a/drivers/misc/hi6421v600-irq.c
+++ b/drivers/misc/hi6421v600-irq.c
@@ -211,6 +211,16 @@ static void hi6421v600_irq_init(struct hi6421v600_irq *priv)
}
}

+static void hi6421v600_irq_domain_remove(void *data)
+{
+ struct hi6421v600_irq *priv = data;
+ int i;
+
+ for (i = 0; i < PMIC_IRQ_LIST_MAX; i++)
+ irq_dispose_mapping(priv->irqs[i]);
+ irq_domain_remove(priv->domain);
+}
+
static int hi6421v600_irq_probe(struct platform_device *pdev)
{
struct device *pmic_dev = pdev->dev.parent;
@@ -260,6 +270,10 @@ static int hi6421v600_irq_probe(struct platform_device *pdev)
return -ENODEV;
}

+ ret = devm_add_action_or_reset(dev, hi6421v600_irq_domain_remove, priv);
+ if (ret)
+ return ret;
+
for (i = 0; i < PMIC_IRQ_LIST_MAX; i++) {
virq = irq_create_mapping(priv->domain, i);
if (!virq) {

base-commit: 86266f137b5c18d477a2df8168149203852b037d
--
2.43.0