]>
Commit | Line | Data |
---|---|---|
a4b7cc35 GKH |
1 | From c3422ad5f84a66739ec6a37251ca27638c85b6be Mon Sep 17 00:00:00 2001 |
2 | From: "Gustavo A. R. Silva" <gustavo@embeddedor.com> | |
3 | Date: Mon, 18 Mar 2019 11:14:39 -0500 | |
4 | Subject: power: supply: axp288_charger: Fix unchecked return value | |
5 | ||
6 | From: Gustavo A. R. Silva <gustavo@embeddedor.com> | |
7 | ||
8 | commit c3422ad5f84a66739ec6a37251ca27638c85b6be upstream. | |
9 | ||
10 | Currently there is no check on platform_get_irq() return value | |
11 | in case it fails, hence never actually reporting any errors and | |
12 | causing unexpected behavior when using such value as argument | |
13 | for function regmap_irq_get_virq(). | |
14 | ||
15 | Fix this by adding a proper check, a message reporting any errors | |
16 | and returning *pirq* | |
17 | ||
18 | Addresses-Coverity-ID: 1443940 ("Improper use of negative value") | |
19 | Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver") | |
20 | Cc: stable@vger.kernel.org | |
21 | Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> | |
22 | Reviewed-by: Hans de Goede <hdegoede@redhat.com> | |
23 | Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> | |
24 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
25 | ||
26 | --- | |
27 | drivers/power/supply/axp288_charger.c | 4 ++++ | |
28 | 1 file changed, 4 insertions(+) | |
29 | ||
30 | --- a/drivers/power/supply/axp288_charger.c | |
31 | +++ b/drivers/power/supply/axp288_charger.c | |
32 | @@ -832,6 +832,10 @@ static int axp288_charger_probe(struct p | |
33 | /* Register charger interrupts */ | |
34 | for (i = 0; i < CHRG_INTR_END; i++) { | |
35 | pirq = platform_get_irq(info->pdev, i); | |
36 | + if (pirq < 0) { | |
37 | + dev_err(&pdev->dev, "Failed to get IRQ: %d\n", pirq); | |
38 | + return pirq; | |
39 | + } | |
40 | info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq); | |
41 | if (info->irq[i] < 0) { | |
42 | dev_warn(&info->pdev->dev, |