Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers
Subsystems (8)
v2 cover Stop calling devm_request_irq() with invalid IRQs in the I2C bus drivers
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
PATCH v2 1/6 i2c: cadence: add IRQ check
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.
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-cadence.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-cadence.c +4 -1
@@ -1200,7 +1200,10 @@ static int cdns_i2c_probe(struct platforif (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;
PATCH v2 2/6 i2c: emev2: add IRQ check
In reply to Sergey ShtylyovThe 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.
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-emev2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-emev2.c +4 -1
@@ -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)
PATCH v2 3/6 i2c: jz4780: add IRQ check
In reply to Sergey ShtylyovThe 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.
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-jz4780.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-jz4780.c +4 -1
@@ -825,7 +825,10 @@ static int jz4780_i2c_probe(struct platfjz4780_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)
PATCH v2 4/6 i2c: mlxbf: add IRQ check
In reply to Sergey ShtylyovThe 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.
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-mlxbf.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-mlxbf.c +2 -0
@@ -2376,6 +2376,8 @@ static int mlxbf_i2c_probe(struct platfomlxbf_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);
PATCH v2 5/6 i2c: rcar: add IRQ check
In reply to Sergey ShtylyovThe 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.
---
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(-)
drivers/i2c/busses/i2c-rcar.c +4 -1
@@ -1027,7 +1027,10 @@ static int rcar_i2c_probe(struct platforif (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);
PATCH v2 6/6 i2c: sh7760: add IRQ check
In reply to Sergey ShtylyovThe 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.
---
Changes in version 2:
- new patch.
drivers/i2c/busses/i2c-sh7760.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-sh7760.c +4 -1
@@ -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;
Re: [PATCH v2 6/6] i2c: sh7760: add IRQ check
Quoted 21 lines · Sergey Shtylyov
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 callingdevm_request_irq()with invalid IRQ #s.Fixes a26c20b1fa6d ("i2c: Renesas SH7760 I2C master driver")Signed-off-by Sergey Shtylyov <[email protected]>---
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
===================================================================
drivers/i2c/busses/i2c-sh7760.c static int sh7760_i2c_probe(struct platf · line 476
Quoted 7 lines
drivers/i2c/busses/i2c-sh7760.c +3
-1@@ -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
Re: [PATCH v2 6/6] i2c: sh7760: add IRQ check
Quoted 7 lines
drivers/i2c/busses/i2c-sh7760.c static int sh7760_i2c_probe(struct platf · line 476
Quoted 5 lines
drivers/i2c/busses/i2c-sh7760.c +3
-1- 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! :-/
Please send an incremental patch. Thanks!
Quoted 10 lines · Sergey Shtylyov
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 todevm_request_irq()which expects *unsinged* IRQ #s. Stop doing that by checking what exactlyplatform_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.
Quoted 1 line
[6/6] i2c: sh7760: add IRQ check
MBR, Sergey
Quoted 1 line · Sergey Shtylyov
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... :-)
Quoted 3 lines
The affected drivers call
platform_get_irq()but largely ignore its result -- they blithely pass the negative error codes todevm_request_irq()which expects *unsinged* IRQ #s. Stop doing that by checking what exactlyplatform_get_irq()returns.
[...]
MNR, Sergey
Quoted 11 lines · Sergey Shtylyov
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 todevm_request_irq()which expects *unsinged* IRQ #s. Stop doing that by checking what exactlyplatform_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!
PATCH 1/1 i2c: sh7760: fix IRQ error path
In reply to Sergey ShtylyovWhile 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!
---
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(-)
drivers/i2c/busses/i2c-sh7760.c +1 -1
@@ -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;
Wolfram Sang
AppliedRe: [PATCH] i2c: sh7760: fix IRQ error path
Quoted 8 lines · Sergey Shtylyov
While adding the invalid IRQ check after calling
platform_get_irq(), I managed to overlook that the driver has a complex error path in itsprobe()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 <[email protected]>
Applied to for-next, thanks!