Linux Power Management development
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Sebastian Reichel <sre@kernel.org>, linux-pm@vger.kernel.org
Cc: Wenyou Yang <wenyou.yang@atmel.com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Subject: [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check
Date: Sun, 16 Jul 2017 20:52:20 +0300	[thread overview]
Message-ID: <20170716175244.300670810@cogentembedded.com> (raw)

[-- 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,

             reply	other threads:[~2017-07-16 17:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-16 17:52 Sergei Shtylyov [this message]
2017-07-16 17:55 ` [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170716175244.300670810@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=wenyou.yang@atmel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox