Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check
@ 2017-07-16 17:52 Sergei Shtylyov
  2017-07-16 17:55 ` Sergei Shtylyov
  2017-07-24 18:54 ` Sebastian Reichel
  0 siblings, 2 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2017-07-16 17:52 UTC (permalink / raw)
  To: Sebastian Reichel, linux-pm; +Cc: Wenyou Yang, Sergei Shtylyov

[-- Attachment #1: power-supply-act8945a_charger-fix-of_irq_get-error-check.patch --]
[-- Type: text/plain, Size: 1346 bytes --]

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")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

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

Index: linux/drivers/power/supply/act8945a_charger.c
===================================================================
--- linux.orig/drivers/power/supply/act8945a_charger.c
+++ 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,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check
  2017-07-16 17:52 [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check Sergei Shtylyov
@ 2017-07-16 17:55 ` Sergei Shtylyov
  2017-07-17 10:50   ` Sebastian Reichel
  2017-07-24 18:54 ` Sebastian Reichel
  1 sibling, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2017-07-16 17:55 UTC (permalink / raw)
  To: Sebastian Reichel, linux-pm; +Cc: Wenyou Yang

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check
  2017-07-16 17:55 ` Sergei Shtylyov
@ 2017-07-17 10:50   ` Sebastian Reichel
  2017-07-17 12:00     ` Sergei Shtylyov
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Reichel @ 2017-07-17 10:50 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-pm, Wenyou Yang

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

Hi,

On Sun, Jul 16, 2017 at 08:55:13PM +0300, Sergei Shtylyov wrote:
> 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check
  2017-07-17 10:50   ` Sebastian Reichel
@ 2017-07-17 12:00     ` Sergei Shtylyov
  2017-07-17 13:23       ` Sebastian Reichel
  0 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2017-07-17 12:00 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, Wenyou Yang

Hello!

On 07/17/2017 01:50 PM, Sebastian Reichel wrote:

>> 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.

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

MBR, Sergei

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check
  2017-07-17 12:00     ` Sergei Shtylyov
@ 2017-07-17 13:23       ` Sebastian Reichel
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2017-07-17 13:23 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-pm, Wenyou Yang

[-- Attachment #1: Type: text/plain, Size: 867 bytes --]

Hi,

On Mon, Jul 17, 2017 at 03:00:26PM +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 07/17/2017 01:50 PM, Sebastian Reichel wrote:
> 
> > > 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.

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

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check
  2017-07-16 17:52 [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check Sergei Shtylyov
  2017-07-16 17:55 ` Sergei Shtylyov
@ 2017-07-24 18:54 ` Sebastian Reichel
  1 sibling, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2017-07-24 18:54 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-pm, Wenyou Yang

[-- Attachment #1: Type: text/plain, Size: 1587 bytes --]

Hi,

On Sun, Jul 16, 2017 at 08:52:20PM +0300, Sergei Shtylyov wrote:
> 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")
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

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

-- Sebastian

> ---
>  drivers/power/supply/act8945a_charger.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Index: linux/drivers/power/supply/act8945a_charger.c
> ===================================================================
> --- linux.orig/drivers/power/supply/act8945a_charger.c
> +++ 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,
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-24 18:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-16 17:52 [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check Sergei Shtylyov
2017-07-16 17:55 ` Sergei Shtylyov
2017-07-17 10:50   ` Sebastian Reichel
2017-07-17 12:00     ` Sergei Shtylyov
2017-07-17 13:23       ` Sebastian Reichel
2017-07-24 18:54 ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox