Skip to contentSkip to conversation

power: supply: Added check for negative values

PATCH In review Denis Arefev 3 participants 3 messages Dec 6, 2022 – Jan 2, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: Added check for negative values

Variable 'pirq', which may receive negative value in platform_get_irq().
Used as an index in a function regmap_irq_get_virq().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/power/supply/axp288_fuel_gauge.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/power/supply/axp288_fuel_gauge.c +2 -0
index 148eb8105803..36c7039c99c2 100644
@@ -640,6 +640,8 @@ static void fuel_gauge_init_irq(struct axp288_fg_info *info)
 
 	for (i = 0; i < AXP288_FG_INTR_NUM; i++) {
 		pirq = platform_get_irq(info->pdev, i);
+		if (pirq < 0)
+			continue;
 		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.25.1
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 7 lines · Denis Arefev

Variable 'pirq', which may receive negative value in platform_get_irq().
Used as an index in a function regmap_irq_get_virq().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 17 lines
---
 drivers/power/supply/axp288_fuel_gauge.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/power/supply/axp288_fuel_gauge.c +2 -0
index 148eb8105803..36c7039c99c2 100644
@@ -640,6 +640,8 @@ static void fuel_gauge_init_irq(struct axp288_fg_info *info)
 
 	for (i = 0; i < AXP288_FG_INTR_NUM; i++) {
 		pirq = platform_get_irq(info->pdev, i);
+		if (pirq < 0)
+			continue;
 		info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq);
 		if (info->irq[i] < 0) {
 			dev_warn(&info->pdev->dev,
#2 lore raw

Hi,

Quoted 11 lines · Hans de Goede

Hi,

Quoted 7 lines · Denis Arefev

Variable 'pirq', which may receive negative value in platform_get_irq().
Used as an index in a function regmap_irq_get_virq().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Quoted 7 lines

Thanks, patch looks good to me:

Regards,

Hans

Thanks, queued to power-supply's fixes branch.

-- Sebastian

Quoted 19 lines
Quoted 18 lines
---
 drivers/power/supply/axp288_fuel_gauge.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/power/supply/axp288_fuel_gauge.c +2 -0
index 148eb8105803..36c7039c99c2 100644
@@ -640,6 +640,8 @@ static void fuel_gauge_init_irq(struct axp288_fg_info *info)
 
 	for (i = 0; i < AXP288_FG_INTR_NUM; i++) {
 		pirq = platform_get_irq(info->pdev, i);
+		if (pirq < 0)
+			continue;
 		info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq);
 		if (info->irq[i] < 0) {
 			dev_warn(&info->pdev->dev,