power: supply: axp288_charger: Fix unchecked return value
PATCH 1/1 power: supply: axp288_charger: Fix unchecked return value
Currently there is no check on platform_get_irq() return value in case it fails, hence never actually reporting any errors and causing unexpected behavior when using such value as argument for function regmap_irq_get_virq().
Fix this by adding a proper check, a message reporting any errors and returning *pirq*
Addresses-Coverity-ID: 1443940 ("Improper use of negative value")
--- drivers/power/supply/axp288_charger.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/power/supply/axp288_charger.c +4 -0
@@ -833,6 +833,10 @@ static int axp288_charger_probe(struct platform_device *pdev)/* Register charger interrupts */ for (i =0 ; i <CHRG_INTR_END ; i++) { pirq =platform_get_irq (info->pdev, i); +if (pirq <0 ) { +dev_err (&pdev->dev,"Failed to get IRQ: %d\n" , pirq); +return pirq; + } info->irq[i] =regmap_irq_get_virq (info->regmap_irqc, pirq);if (info->irq[i] <0 ) { dev_warn(&info->pdev->dev,
Signature · 1 line
2.21.0
Hi,
Quoted 22 lines · Gustavo A. R. Silva
Currently there is no check on
platform_get_irq()return value in case it fails, hence never actually reporting any errors and causing unexpected behavior when using such value as argument for functionregmap_irq_get_virq().Fix this by adding a proper check, a message reporting any errors and returning *pirq*
Addresses-Coverity-ID: 1443940 ("Improper use of negative value")
Fixes 843735b788a4 ("power: axp288_charger: axp288 charger driver")Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/power/supply/axp288_charger.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/power/supply/axp288_charger.c +0
-0
drivers/power/supply/axp288_charger.c static int axp288_charger_probe(struct platform_device *pdev) · line 842
Quoted 10 lines
drivers/power/supply/axp288_charger.c +4
-0@@ -833,6 +833,10 @@ static int axp288_charger_probe(struct platform_device *pdev)/* Register charger interrupts */ for (i =0 ; i <CHRG_INTR_END ; i++) { pirq =platform_get_irq (info->pdev, i); +if (pirq <0 ) { +dev_err (&pdev->dev,"Failed to get IRQ: %d\n" , pirq); +return pirq; + } info->irq[i] =regmap_irq_get_virq (info->regmap_irqc, pirq);if (info->irq[i] <0 ) { dev_warn(&info->pdev->dev,
Patch looks good to me:
Regards,
Hans
Sebastian Reichel
maintainerHi,
Quoted 38 lines · Hans de Goede
Hi,
Quoted 22 lines · Gustavo A. R. Silva
Currently there is no check on
platform_get_irq()return value in case it fails, hence never actually reporting any errors and causing unexpected behavior when using such value as argument for functionregmap_irq_get_virq().Fix this by adding a proper check, a message reporting any errors and returning *pirq*
Addresses-Coverity-ID: 1443940 ("Improper use of negative value")
Fixes 843735b788a4 ("power: axp288_charger: axp288 charger driver")Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/power/supply/axp288_charger.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/power/supply/axp288_charger.c +0
-0drivers/power/supply/axp288_charger.c static int axp288_charger_probe(struct platform_device *pdev) · line 842
Quoted 10 lines
drivers/power/supply/axp288_charger.c +4
-0@@ -833,6 +833,10 @@ static int axp288_charger_probe(struct platform_device *pdev)/* Register charger interrupts */ for (i =0 ; i <CHRG_INTR_END ; i++) { pirq =platform_get_irq (info->pdev, i); +if (pirq <0 ) { +dev_err (&pdev->dev,"Failed to get IRQ: %d\n" , pirq); +return pirq; + } info->irq[i] =regmap_irq_get_virq (info->regmap_irqc, pirq);if (info->irq[i] <0 ) { dev_warn(&info->pdev->dev,Patch looks good to me:
Quoted 1 line
Reviewed-by Hans de Goede <[email protected]>
Thanks, queued.
-- Sebastian