]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: adc: qcom-spmi-iadc: balance enable_irq_wake() on driver unbind
authorStepan Ionichev <sozdayvek@gmail.com>
Wed, 20 May 2026 19:09:24 +0000 (00:09 +0500)
committerJonathan Cameron <jic23@kernel.org>
Tue, 26 May 2026 18:22:57 +0000 (19:22 +0100)
iadc_probe() calls enable_irq_wake() after a successful
devm_request_irq(), but the driver has no remove callback or
matching disable_irq_wake(), so the wake reference count on the
IRQ is leaked on module unload or driver unbind.

Check the IRQ request error first, then register a devm action
that calls disable_irq_wake() so the wake reference is released
in the same scope as the enable. While here, drop the inverted
"if (!ret) ... else return ret" in favour of the standard
"if (ret) return ret;" pattern.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/qcom-spmi-iadc.c

index b64a8a407168bbc109e6ea9a63b8c4e492ac5bf4..0ec3a0c4b1de00f5586ec883f4514270a384d6b4 100644 (file)
@@ -481,6 +481,11 @@ static const struct iio_chan_spec iadc_channels[] = {
        },
 };
 
+static void iadc_disable_irq_wake(void *data)
+{
+       disable_irq_wake((unsigned long)data);
+}
+
 static int iadc_probe(struct platform_device *pdev)
 {
        struct device_node *node = pdev->dev.of_node;
@@ -538,9 +543,16 @@ static int iadc_probe(struct platform_device *pdev)
        if (!iadc->poll_eoc) {
                ret = devm_request_irq(dev, irq_eoc, iadc_isr, 0,
                                        "spmi-iadc", iadc);
-               if (!ret)
-                       enable_irq_wake(irq_eoc);
-               else
+               if (ret)
+                       return ret;
+
+               ret = enable_irq_wake(irq_eoc);
+               if (ret)
+                       return ret;
+
+               ret = devm_add_action_or_reset(dev, iadc_disable_irq_wake,
+                                              (void *)(unsigned long)irq_eoc);
+               if (ret)
                        return ret;
        } else {
                ret = devm_device_init_wakeup(iadc->dev);