* [PATCH] power: supply: axp288_charger: Fix unchecked return value
@ 2019-03-18 16:14 Gustavo A. R. Silva
2019-03-18 17:32 ` Hans de Goede
0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-18 16:14 UTC (permalink / raw)
To: Sebastian Reichel, Hans de Goede, Chen-Yu Tsai,
Ramakrishna Pallala
Cc: linux-pm, linux-kernel, 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 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")
Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/power/supply/axp288_charger.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
index f8c6da9277b3..00b961890a38 100644
--- a/drivers/power/supply/axp288_charger.c
+++ b/drivers/power/supply/axp288_charger.c
@@ -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,
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] power: supply: axp288_charger: Fix unchecked return value
2019-03-18 16:14 [PATCH] power: supply: axp288_charger: Fix unchecked return value Gustavo A. R. Silva
@ 2019-03-18 17:32 ` Hans de Goede
2019-04-05 14:04 ` Sebastian Reichel
0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2019-03-18 17:32 UTC (permalink / raw)
To: Gustavo A. R. Silva, Sebastian Reichel, Chen-Yu Tsai,
Ramakrishna Pallala
Cc: linux-pm, linux-kernel
Hi,
On 18-03-19 17:14, Gustavo A. R. Silva wrote:
> 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")
> Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/power/supply/axp288_charger.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
> index f8c6da9277b3..00b961890a38 100644
> --- a/drivers/power/supply/axp288_charger.c
> +++ b/drivers/power/supply/axp288_charger.c
> @@ -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:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] power: supply: axp288_charger: Fix unchecked return value
2019-03-18 17:32 ` Hans de Goede
@ 2019-04-05 14:04 ` Sebastian Reichel
2019-04-05 14:04 ` Sebastian Reichel
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Reichel @ 2019-04-05 14:04 UTC (permalink / raw)
To: Hans de Goede
Cc: Gustavo A. R. Silva, Chen-Yu Tsai, Ramakrishna Pallala, linux-pm,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]
Hi,
On Mon, Mar 18, 2019 at 06:32:35PM +0100, Hans de Goede wrote:
> Hi,
>
> On 18-03-19 17:14, Gustavo A. R. Silva wrote:
> > 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")
> > Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> > ---
> > drivers/power/supply/axp288_charger.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
> > index f8c6da9277b3..00b961890a38 100644
> > --- a/drivers/power/supply/axp288_charger.c
> > +++ b/drivers/power/supply/axp288_charger.c
> > @@ -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:
>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Thanks, queued.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] power: supply: axp288_charger: Fix unchecked return value
2019-04-05 14:04 ` Sebastian Reichel
@ 2019-04-05 14:04 ` Sebastian Reichel
0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2019-04-05 14:04 UTC (permalink / raw)
To: Hans de Goede
Cc: Gustavo A. R. Silva, Chen-Yu Tsai, Ramakrishna Pallala, linux-pm,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]
Hi,
On Mon, Mar 18, 2019 at 06:32:35PM +0100, Hans de Goede wrote:
> Hi,
>
> On 18-03-19 17:14, Gustavo A. R. Silva wrote:
> > 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")
> > Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> > ---
> > drivers/power/supply/axp288_charger.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
> > index f8c6da9277b3..00b961890a38 100644
> > --- a/drivers/power/supply/axp288_charger.c
> > +++ b/drivers/power/supply/axp288_charger.c
> > @@ -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:
>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Thanks, queued.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-05 14:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-18 16:14 [PATCH] power: supply: axp288_charger: Fix unchecked return value Gustavo A. R. Silva
2019-03-18 17:32 ` Hans de Goede
2019-04-05 14:04 ` Sebastian Reichel
2019-04-05 14:04 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox