power: supply: act8945a_charger: fix of_irq_get() error check
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Sun, 16 Jul 2017 17:52:20 +0000 (20:52 +0300)
committerSebastian Reichel <sre@kernel.org>
Mon, 24 Jul 2017 12:09:00 +0000 (14:09 +0200)
of_irq_get() may return any negative error number as well as 0 on failure,
while the driver only checks for -EPROBE_DEFER, blithely continuing with
the call to devm_request_irq() -- that function expects *unsigned int*,
so would probably fail anyway when a large IRQ number resulting from a
conversion of a negative error number is passed to it... This, however,
is incorrect behavior -- error number is not IRQ number.

Check for 'irq <= 0' instead and return -ENXIO from probe if of_irq_get()
returned 0.

Fixes: a09209acd6a8 ("power: supply: act8945a_charger: Add status change update support")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/power/supply/act8945a_charger.c

index d1eb2e359532d0588a189c85a6011149230bfae7..8e117b31ba79116237729a319ed7e57edfa27aad 100644 (file)
@@ -596,9 +596,9 @@ static int act8945a_charger_probe(struct platform_device *pdev)
                return ret;
 
        irq = of_irq_get(pdev->dev.of_node, 0);
-       if (irq == -EPROBE_DEFER) {
+       if (irq <= 0) {
                dev_err(&pdev->dev, "failed to find IRQ number\n");
-               return -EPROBE_DEFER;
+               return irq ?: -ENXIO;
        }
 
        ret = devm_request_irq(&pdev->dev, irq, act8945a_status_changed,