linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Bjorn Helgaas <bhelgaas@google.com>, linux-pci@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Subject: [PATCH] pci: ftpci100: fix of_irq_get() error check
Date: Sun, 16 Jul 2017 00:43:10 +0300	[thread overview]
Message-ID: <20170715214406.657273405@cogentembedded.com> (raw)

of_irq_get() may return a negative error number as well as 0 on failure,
while the driver only checks for 0, blithely continuing with the call to
irq_set_chained_handler_and_data() -- that function expects *unsigned int*
so should probably do nothing when a large IRQ number resulting from a
conversion of a negative error number is passed to it. The driver then
probes successfully while being only partly functional...

Check for 'irq <= 0' instead and propagate the negative error number to
the probe method --  that will allow the deferred probing as well...

Fixes: d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/pci/host/pci-ftpci100.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: pci/drivers/pci/host/pci-ftpci100.c
===================================================================
--- pci.orig/drivers/pci/host/pci-ftpci100.c
+++ pci/drivers/pci/host/pci-ftpci100.c
@@ -350,9 +350,9 @@ static int faraday_pci_setup_cascaded_ir
 
 	/* All PCI IRQs cascade off this one */
 	irq = of_irq_get(intc, 0);
-	if (!irq) {
+	if (irq <= 0) {
 		dev_err(p->dev, "failed to get parent IRQ\n");
-		return -EINVAL;
+		return irq ?: -EINVAL;
 	}
 
 	p->irqdomain = irq_domain_add_linear(intc, 4,

             reply	other threads:[~2017-07-15 21:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-15 21:43 Sergei Shtylyov [this message]
2017-07-15 21:56 ` [PATCH] pci: ftpci100: fix of_irq_get() error check Sergei Shtylyov
2017-07-16 21:17 ` Linus Walleij
2017-07-17  9:55   ` Sergei Shtylyov
2017-08-02 21:36 ` Bjorn Helgaas
2017-08-03  9:32   ` Sergei Shtylyov
2017-08-03 16:15     ` Bjorn Helgaas
2017-08-03 16:23       ` Sergei Shtylyov

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=20170715214406.657273405@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=bhelgaas@google.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-pci@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).