Skip to contentSkip to conversation

power: supply: act8945a_charger: fix of_irq_get() error check

PATCH Applied Sergei Shtylyov 2 participants 6 messages Jul 16, 2017 – Jul 24, 2017 Power supply

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: act8945a_charger: fix of_irq_get() error check

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")
---
 drivers/power/supply/act8945a_charger.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/act8945a_charger.c +2 -2
Index: linux/drivers/power/supply/act8945a_charger.c
===================================================================
@@ -596,9 +596,9 @@ static int act8945a_charger_probe(struct
 		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,
#1 lore raw

Forgot to mention that this patch is against Linus' repo as Sebastian's repo lags behind at 4.10-rc1...

#2 lore raw

Hi,

Quoted 2 lines · Sergei Shtylyov

Forgot to mention that this patch is against Linus' repo as Sebastian's repo lags behind at 4.10-rc1...

You are supposed to use my for-next branch [0] and not master :) That one was 4.12-rc1 + power supply patches until a few hours ago and now is 4.13-rc1. So if you based on current master from Linus it should be ok. I will start reviewing patches for the v4.14 cycle shortly.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/log/?h=for-next

-- Sebastian

#3 lore raw

Hello!

Quoted 8 lines · Sebastian Reichel
Quoted 2 lines

Forgot to mention that this patch is against Linus' repo as Sebastian's repo lags behind at 4.10-rc1...

You are supposed to use my for-next branch [0] and not master :) That one was 4.12-rc1 + power supply patches until a few hours ago and now is 4.13-rc1. So if you based on current master from Linus it should be ok. I will start reviewing patches for the v4.14 cycle shortly.

I first tried to use 'fixes' but that one was at 4.8-rc1, then switched to
back to 'master'.
Since this patch is a bug fix, I didn't consider for-next.

Quoted 3 lines

[0] https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/log/?h=for-next

-- Sebastian

MBR, Sergei

#4 lore raw

Hi,

Quoted 13 lines · Sergei Shtylyov

Hello!

Quoted 8 lines · Sebastian Reichel
Quoted 2 lines

Forgot to mention that this patch is against Linus' repo as Sebastian's repo lags behind at 4.10-rc1...

You are supposed to use my for-next branch [0] and not master :) That one was 4.12-rc1 + power supply patches until a few hours ago and now is 4.13-rc1. So if you based on current master from Linus it should be ok. I will start reviewing patches for the v4.14 cycle shortly.

Quoted 3 lines

I first tried to use 'fixes' but that one was at 4.8-rc1, then switched to back to 'master'. Since this patch is a bug fix, I didn't consider for-next.

Right, I did not check carefully enough. I often do not have to send any fixes, so that branch tends to get stale.

-- Sebastian

maintainer Applied
#5 lore raw
In reply to Sergei Shtylyov

Hi,

Quoted 7 lines · Sergei Shtylyov

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.

Quoted 5 lines

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")

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

-- Sebastian

Quoted 21 lines
---
 drivers/power/supply/act8945a_charger.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux/drivers/power/supply/act8945a_charger.c
===================================================================

drivers/power/supply/act8945a_charger.c +2 -2
@@ -596,9 +596,9 @@ static int act8945a_charger_probe(struct
 		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,