linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers
@ 2021-04-10 20:11 Sergey Shtylyov
  2021-04-10 20:18 ` [PATCH v2 3/6] i2c: jz4780: add IRQ check Sergey Shtylyov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:11 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang, Khalil Blaiech, Paul Cercueil,
	Michal Simek
  Cc: linux-mips, linux-arm-kernel

Here are 6 patches against the 'master' branch of Martin Petersen's 'scsi.git' repo.
The affected drivers call platform_get_irq() but largely ignore its result -- they
blithely pass the negative error codes to devm_request_irq() which expects *unsinged*
IRQ #s. Stop doing that by checking what exactly platform_get_irq() returns.

[1/6] i2c: cadence: add IRQ check
[2/6] i2c: emev2: add IRQ check
[3/6] i2c: jz4780: add IRQ check
[4/6] i2c: mlxbf: add IRQ check
[5/6] i2c: rcar: add IRQ check
[6/6] i2c: sh7760: add IRQ check

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

* [PATCH v2 3/6] i2c: jz4780: add IRQ check
  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:18 ` Sergey Shtylyov
  2021-04-10 20:31 ` [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers Sergey Shtylyov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:18 UTC (permalink / raw)
  To: linux-i2c, Paul Cercueil; +Cc: linux-mips

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: ba92222ed63a ("i2c: jz4780: Add i2c bus controller driver for Ingenic JZ4780")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>

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

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

Index: linux/drivers/i2c/busses/i2c-jz4780.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-jz4780.c
+++ linux/drivers/i2c/busses/i2c-jz4780.c
@@ -825,7 +825,10 @@ static int jz4780_i2c_probe(struct platf
 
 	jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0);
 
-	i2c->irq = platform_get_irq(pdev, 0);
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		goto err;
+	i2c->irq = ret;
 	ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0,
 			       dev_name(&pdev->dev), i2c);
 	if (ret)

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

* Re: [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers
  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:18 ` [PATCH v2 3/6] i2c: jz4780: add IRQ check Sergey Shtylyov
@ 2021-04-10 20:31 ` Sergey Shtylyov
  2021-04-10 20:57 ` Sergey Shtylyov
  2021-04-14  8:22 ` Wolfram Sang
  3 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:31 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang, Khalil Blaiech, Paul Cercueil,
	Michal Simek
  Cc: linux-mips, linux-arm-kernel

On 4/10/21 11:11 PM, Sergey Shtylyov wrote:

> Here are 6 patches against the 'master' branch of Martin Petersen's 'scsi.git' repo.
> The affected drivers call platform_get_irq() but largely ignore its result -- they
> blithely pass the negative error codes to devm_request_irq() which expects *unsinged*
> IRQ #s. Stop doing that by checking what exactly platform_get_irq() returns.
> 
> [1/6] i2c: cadence: add IRQ check
> [2/6] i2c: emev2: add IRQ check
> [3/6] i2c: jz4780: add IRQ check
> [4/6] i2c: mlxbf: add IRQ check
> [5/6] i2c: rcar: add IRQ check

   Forgot to mention that the whole v2 patch set grew from this R-Car patch.

> [6/6] i2c: sh7760: add IRQ check

MBR, Sergey

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

* Re: [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers
  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:18 ` [PATCH v2 3/6] i2c: jz4780: add IRQ check Sergey Shtylyov
  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
  3 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:57 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang, Khalil Blaiech, Paul Cercueil,
	Michal Simek
  Cc: linux-mips, linux-arm-kernel

On 4/10/21 11:11 PM, Sergey Shtylyov wrote:

> Here are 6 patches against the 'master' branch of Martin Petersen's 'scsi.git' repo.

   Oops, left that line unfinished. Wolfram's 'linux.git' repo, of course... :-)

> The affected drivers call platform_get_irq() but largely ignore its result -- they
> blithely pass the negative error codes to devm_request_irq() which expects *unsinged*
> IRQ #s. Stop doing that by checking what exactly platform_get_irq() returns.

[...]

MNR, Sergey

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

* Re: [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers
  2021-04-10 20:11 [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers Sergey Shtylyov
                   ` (2 preceding siblings ...)
  2021-04-10 20:57 ` Sergey Shtylyov
@ 2021-04-14  8:22 ` Wolfram Sang
  3 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2021-04-14  8:22 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: linux-i2c, Khalil Blaiech, Paul Cercueil, Michal Simek,
	linux-mips, linux-arm-kernel

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

On Sat, Apr 10, 2021 at 11:11:59PM +0300, Sergey Shtylyov wrote:
> Here are 6 patches against the 'master' branch of Martin Petersen's 'scsi.git' repo.
> The affected drivers call platform_get_irq() but largely ignore its result -- they
> blithely pass the negative error codes to devm_request_irq() which expects *unsinged*
> IRQ #s. Stop doing that by checking what exactly platform_get_irq() returns.
> 
> [1/6] i2c: cadence: add IRQ check
> [2/6] i2c: emev2: add IRQ check
> [3/6] i2c: jz4780: add IRQ check
> [4/6] i2c: mlxbf: add IRQ check
> [5/6] i2c: rcar: add IRQ check
> [6/6] i2c: sh7760: add IRQ check

Applied to for-next, thanks!


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

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

end of thread, other threads:[~2021-04-14  8:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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:18 ` [PATCH v2 3/6] i2c: jz4780: add IRQ check Sergey Shtylyov
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

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