* [PATCH v2 1/6] i2c: cadence: 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:14 ` Sergey Shtylyov
2021-04-10 20:16 ` [PATCH v2 2/6] i2c: emev2: " Sergey Shtylyov
` (8 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:14 UTC (permalink / raw)
To: linux-i2c, Michal Simek; +Cc: linux-arm-kernel
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;
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 2/6] i2c: emev2: 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:14 ` [PATCH v2 1/6] i2c: cadence: add IRQ check Sergey Shtylyov
@ 2021-04-10 20:16 ` Sergey Shtylyov
2021-04-10 20:18 ` [PATCH v2 3/6] i2c: jz4780: " Sergey Shtylyov
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:16 UTC (permalink / raw)
To: linux-i2c, Wolfram Sang
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: 5faf6e1f58b4 ("i2c: emev2: add driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-emev2.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: linux/drivers/i2c/busses/i2c-emev2.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-emev2.c
+++ linux/drivers/i2c/busses/i2c-emev2.c
@@ -395,7 +395,10 @@ static int em_i2c_probe(struct platform_
em_i2c_reset(&priv->adap);
- priv->irq = platform_get_irq(pdev, 0);
+ ret = platform_get_irq(pdev, 0);
+ if (ret < 0)
+ goto err_clk;
+ priv->irq = ret;
ret = devm_request_irq(&pdev->dev, priv->irq, em_i2c_irq_handler, 0,
"em_i2c", priv);
if (ret)
^ permalink raw reply [flat|nested] 14+ 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:14 ` [PATCH v2 1/6] i2c: cadence: add IRQ check Sergey Shtylyov
2021-04-10 20:16 ` [PATCH v2 2/6] i2c: emev2: " Sergey Shtylyov
@ 2021-04-10 20:18 ` Sergey Shtylyov
2021-04-10 20:20 ` [PATCH v2 4/6] i2c: mlxbf: " Sergey Shtylyov
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH v2 4/6] i2c: mlxbf: 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
` (2 preceding siblings ...)
2021-04-10 20:18 ` [PATCH v2 3/6] i2c: jz4780: " Sergey Shtylyov
@ 2021-04-10 20:20 ` Sergey Shtylyov
2021-04-10 20:23 ` [PATCH v2 5/6] i2c: rcar: " Sergey Shtylyov
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:20 UTC (permalink / raw)
To: linux-i2c, Khalil Blaiech
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: b5b5b32081cd ("i2c: mlxbf: I2C SMBus driver for Mellanox BlueField SoC")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-mlxbf.c | 2 ++
1 file changed, 2 insertions(+)
Index: linux/drivers/i2c/busses/i2c-mlxbf.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-mlxbf.c
+++ linux/drivers/i2c/busses/i2c-mlxbf.c
@@ -2376,6 +2376,8 @@ static int mlxbf_i2c_probe(struct platfo
mlxbf_i2c_init_slave(pdev, priv);
irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
ret = devm_request_irq(dev, irq, mlxbf_smbus_irq,
IRQF_ONESHOT | IRQF_SHARED | IRQF_PROBE_SHARED,
dev_name(dev), priv);
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 5/6] i2c: rcar: 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
` (3 preceding siblings ...)
2021-04-10 20:20 ` [PATCH v2 4/6] i2c: mlxbf: " Sergey Shtylyov
@ 2021-04-10 20:23 ` Sergey Shtylyov
2021-04-10 20:25 ` [PATCH v2 6/6] i2c: sh7760: " Sergey Shtylyov
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:23 UTC (permalink / raw)
To: linux-i2c, Wolfram Sang; +Cc: linux-renesas-soc
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 the
invalid IRQ #s.
Fixes: 6ccbe607132b ("i2c: add Renesas R-Car I2C driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Changes in version 2:
- avoided a string of assignements;
- added Geert's tag.
drivers/i2c/busses/i2c-rcar.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: linux/drivers/i2c/busses/i2c-rcar.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-rcar.c
+++ linux/drivers/i2c/busses/i2c-rcar.c
@@ -1027,7 +1027,10 @@ static int rcar_i2c_probe(struct platfor
if (of_property_read_bool(dev->of_node, "smbus"))
priv->flags |= ID_P_HOST_NOTIFY;
- priv->irq = platform_get_irq(pdev, 0);
+ ret = platform_get_irq(pdev, 0);
+ if (ret < 0)
+ goto out_pm_disable;
+ priv->irq = ret;
ret = devm_request_irq(dev, priv->irq, irqhandler, irqflags, dev_name(dev), priv);
if (ret < 0) {
dev_err(dev, "cannot get irq %d\n", priv->irq);
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 6/6] i2c: sh7760: 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
` (4 preceding siblings ...)
2021-04-10 20:23 ` [PATCH v2 5/6] i2c: rcar: " Sergey Shtylyov
@ 2021-04-10 20:25 ` Sergey Shtylyov
2021-04-15 15:52 ` 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
` (3 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Sergey Shtylyov @ 2021-04-10 20:25 UTC (permalink / raw)
To: linux-i2c
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: a26c20b1fa6d ("i2c: Renesas SH7760 I2C master driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-sh7760.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: linux/drivers/i2c/busses/i2c-sh7760.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-sh7760.c
+++ linux/drivers/i2c/busses/i2c-sh7760.c
@@ -471,7 +471,10 @@ static int sh7760_i2c_probe(struct platf
goto out2;
}
- id->irq = platform_get_irq(pdev, 0);
+ ret = platform_get_irq(pdev, 0);
+ if (ret < 0)
+ return ret;
+ id->irq = ret;
id->adap.nr = pdev->id;
id->adap.algo = &sh7760_i2c_algo;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 6/6] i2c: sh7760: add IRQ check
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
0 siblings, 1 reply; 14+ messages in thread
From: Sergey Shtylyov @ 2021-04-15 15:52 UTC (permalink / raw)
To: linux-i2c
On 4/10/21 11:25 PM, Sergey Shtylyov wrote:
> 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: a26c20b1fa6d ("i2c: Renesas SH7760 I2C master driver")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
>
> ---
> Changes in version 2:
> - new patch.
>
> drivers/i2c/busses/i2c-sh7760.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> Index: linux/drivers/i2c/busses/i2c-sh7760.c
> ===================================================================
> --- linux.orig/drivers/i2c/busses/i2c-sh7760.c
> +++ linux/drivers/i2c/busses/i2c-sh7760.c
> @@ -471,7 +471,10 @@ static int sh7760_i2c_probe(struct platf
> goto out2;
> }
>
> - id->irq = platform_get_irq(pdev, 0);
> + ret = platform_get_irq(pdev, 0);
> + if (ret < 0)
> + return ret;
Should have been *goto* out3. Sorry for my overlook! :-/
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 14+ 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
` (5 preceding siblings ...)
2021-04-10 20:25 ` [PATCH v2 6/6] i2c: sh7760: " Sergey Shtylyov
@ 2021-04-10 20:31 ` Sergey Shtylyov
2021-04-10 20:57 ` Sergey Shtylyov
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ 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] 14+ 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
` (6 preceding siblings ...)
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
9 siblings, 0 replies; 14+ 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] 14+ 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
` (7 preceding siblings ...)
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
9 siblings, 0 replies; 14+ 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] 14+ messages in thread
* [PATCH] i2c: sh7760: fix IRQ error path
2021-04-10 20:11 [PATCH v2 0/6] Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers Sergey Shtylyov
` (8 preceding siblings ...)
2021-04-14 8:22 ` Wolfram Sang
@ 2021-04-17 19:05 ` Sergey Shtylyov
2021-04-17 20:01 ` Wolfram Sang
9 siblings, 1 reply; 14+ messages in thread
From: Sergey Shtylyov @ 2021-04-17 19:05 UTC (permalink / raw)
To: linux-i2c
While adding the invalid IRQ check after calling platform_get_irq(),
I managed to overlook that the driver has a complex error path in its
probe() method, thus a simple *return* couldn't be used. Use a proper
*goto* instead!
Fixes: e5b2e3e74201 ("i2c: sh7760: add IRQ check")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
---
This patch is against the '2c/for-next' branch of Wolfram's 'linux.git' repo.
I wasn't even able to complie-test it though...
drivers/i2c/busses/i2c-sh7760.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/drivers/i2c/busses/i2c-sh7760.c
===================================================================
--- linux.orig/drivers/i2c/busses/i2c-sh7760.c
+++ linux/drivers/i2c/busses/i2c-sh7760.c
@@ -473,7 +473,7 @@ static int sh7760_i2c_probe(struct platf
ret = platform_get_irq(pdev, 0);
if (ret < 0)
- return ret;
+ goto out3;
id->irq = ret;
id->adap.nr = pdev->id;
^ permalink raw reply [flat|nested] 14+ messages in thread