linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Shtylyov <s.shtylyov@omprussia.ru>
To: <linux-i2c@vger.kernel.org>, Michal Simek <michal.simek@xilinx.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Subject: [PATCH v2 1/6] i2c: cadence: add IRQ check
Date: Sat, 10 Apr 2021 23:14:35 +0300	[thread overview]
Message-ID: <7166579b-c058-5c45-2f62-d9610d41a00f@omprussia.ru> (raw)
In-Reply-To: <7995bba1-61dd-baa3-51ea-0fb2fccc19a0@omprussia.ru>

The driver neglects to check the result of platform_get_irq()'s call and
blithely passes the negative error codes to devm_request_irq() (which
takes *unsigned* IRQ #), causing it to fail with -EINVAL, overriding
an original error code.  Stop calling devm_request_irq() with invalid
IRQ #s.

Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>

---
Changes in version 2:
- new patch.

 drivers/i2c/busses/i2c-cadence.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux/drivers/i2c/busses/i2c-cadence.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-cadence.c
+++ linux/drivers/i2c/busses/i2c-cadence.c
@@ -1200,7 +1200,10 @@ static int cdns_i2c_probe(struct platfor
 	if (IS_ERR(id->membase))
 		return PTR_ERR(id->membase);
 
-	id->irq = platform_get_irq(pdev, 0);
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		return ret;
+	id->irq = ret;
 
 	id->adap.owner = THIS_MODULE;
 	id->adap.dev.of_node = pdev->dev.of_node;

  reply	other threads:[~2021-04-10 20:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10 20:11 [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers Sergey Shtylyov
2021-04-10 20:14 ` Sergey Shtylyov [this message]
2021-04-10 20:16 ` [PATCH v2 2/6] i2c: emev2: add IRQ check Sergey Shtylyov
2021-04-10 20:18 ` [PATCH v2 3/6] i2c: jz4780: " Sergey Shtylyov
2021-04-10 20:20 ` [PATCH v2 4/6] i2c: mlxbf: " Sergey Shtylyov
2021-04-10 20:23 ` [PATCH v2 5/6] i2c: rcar: " Sergey Shtylyov
2021-04-10 20:25 ` [PATCH v2 6/6] i2c: sh7760: " Sergey Shtylyov
2021-04-15 15:52   ` Sergey Shtylyov
2021-04-15 19:57     ` Wolfram Sang
2021-04-10 20:31 ` [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers Sergey Shtylyov
2021-04-10 20:57 ` Sergey Shtylyov
2021-04-14  8:22 ` Wolfram Sang
2021-04-17 19:05 ` [PATCH] i2c: sh7760: fix IRQ error path Sergey Shtylyov
2021-04-17 20:01   ` Wolfram Sang

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=7166579b-c058-5c45-2f62-d9610d41a00f@omprussia.ru \
    --to=s.shtylyov@omprussia.ru \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=michal.simek@xilinx.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;
as well as URLs for NNTP newsgroup(s).