i2c: bcm2835: Fix error handling in bcm2835_i2c_probe
Subsystems (3)
PATCH 1/1 i2c: bcm2835: Fix error handling in bcm2835_i2c_probe
In the error handling path, the clk_prepare_enable() function call should be balanced by a corresponding 'clk_disable_unprepare()' call. And clk_set_rate_exclusive calls clk_rate_exclusive_get(), it should be balanced with call to clk_rate_exclusive_put(). , as already done in the remove function.
--- drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-bcm2835.c +16 -5
@@ -454,18 +454,21 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret =clk_prepare_enable (i2c_dev->bus_clk);if (ret) {dev_err (&pdev->dev,"Couldn't prepare clock" ); -return ret; + goto err_put_clk; } i2c_dev->irq =platform_get_irq (pdev,0 ); -if (i2c_dev->irq <0 ) -return i2c_dev->irq; +if (i2c_dev->irq <0 ) { + ret = i2c_dev->irq; + goto err_disable_clk; + } ret =request_irq (i2c_dev->irq, bcm2835_i2c_isr,IRQF_SHARED ,dev_name (&pdev->dev), i2c_dev);if (ret) {dev_err (&pdev->dev,"Could not request IRQ\n" ); -return -ENODEV ; + ret = -ENODEV ; + goto err_disable_clk; } adap = &i2c_dev->adapter;
@@ -489,8 +492,16 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret =i2c_add_adapter (adap);if (ret) -free_irq (i2c_dev->irq, i2c_dev); + goto err_free_irq; + +return ret; +err_free_irq: +free_irq (i2c_dev->irq, i2c_dev); +err_disable_clk: +clk_disable_unprepare (i2c_dev->bus_clk); +err_put_clk: +clk_rate_exclusive_put (i2c_dev->bus_clk);return ret; }
Signature · 1 line
2.17.1
Quoted 8 lines · Miaoqian Lin
In the error handling path, the
clk_prepare_enable()function call should be balanced by a corresponding 'clk_disable_unprepare()' call. Andclk_set_rate_exclusivecallsclk_rate_exclusive_get(), it should be balanced with call toclk_rate_exclusive_put(). , as already done in the remove function.Fixes bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF")Signed-off-by Miaoqian Lin <[email protected]>
Looking for a reviewer here, pretty please?
Quoted 55 lines
--- drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)drivers/i2c/busses/i2c-bcm2835.c +16
-5@@ -454,18 +454,21 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret =clk_prepare_enable (i2c_dev->bus_clk);if (ret) {dev_err (&pdev->dev,"Couldn't prepare clock" ); -return ret; + goto err_put_clk; } i2c_dev->irq =platform_get_irq (pdev,0 ); -if (i2c_dev->irq <0 ) -return i2c_dev->irq; +if (i2c_dev->irq <0 ) { + ret = i2c_dev->irq; + goto err_disable_clk; + } ret =request_irq (i2c_dev->irq, bcm2835_i2c_isr,IRQF_SHARED ,dev_name (&pdev->dev), i2c_dev);if (ret) {dev_err (&pdev->dev,"Could not request IRQ\n" ); -return -ENODEV ; + ret = -ENODEV ; + goto err_disable_clk; } adap = &i2c_dev->adapter;@@ -489,8 +492,16 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret =i2c_add_adapter (adap);if (ret) -free_irq (i2c_dev->irq, i2c_dev); + goto err_free_irq; + +return ret; +err_free_irq: +free_irq (i2c_dev->irq, i2c_dev); +err_disable_clk: +clk_disable_unprepare (i2c_dev->bus_clk); +err_put_clk: +clk_rate_exclusive_put (i2c_dev->bus_clk);return ret; }Signature · 1 line
2.17.1
Le 21/05/2022 à 13:46, Wolfram Sang a écrit :
Quoted 11 lines · Miaoqian Lin
Quoted 8 lines
In the error handling path, the
clk_prepare_enable()function call should be balanced by a corresponding 'clk_disable_unprepare()' call. Andclk_set_rate_exclusivecallsclk_rate_exclusive_get(), it should be balanced with call toclk_rate_exclusive_put(). , as already done in the remove function.Fixes bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF")Signed-off-by Miaoqian Lin <[email protected]>Looking for a reviewer here, pretty please?
Hi,
on which tree are you working?
A similar patch is already available in -next since several months. (see [1])
CJ
Quoted 53 lines
Quoted 53 lines
--- drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)drivers/i2c/busses/i2c-bcm2835.c +16
-5@@ -454,18 +454,21 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret =clk_prepare_enable (i2c_dev->bus_clk);if (ret) {dev_err (&pdev->dev,"Couldn't prepare clock" ); -return ret; + goto err_put_clk; } i2c_dev->irq =platform_get_irq (pdev,0 ); -if (i2c_dev->irq <0 ) -return i2c_dev->irq; +if (i2c_dev->irq <0 ) { + ret = i2c_dev->irq; + goto err_disable_clk; + } ret =request_irq (i2c_dev->irq, bcm2835_i2c_isr,IRQF_SHARED ,dev_name (&pdev->dev), i2c_dev);if (ret) {dev_err (&pdev->dev,"Could not request IRQ\n" ); -return -ENODEV ; + ret = -ENODEV ; + goto err_disable_clk; } adap = &i2c_dev->adapter;@@ -489,8 +492,16 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret =i2c_add_adapter (adap);if (ret) -free_irq (i2c_dev->irq, i2c_dev); + goto err_free_irq; + +return ret; +err_free_irq: +free_irq (i2c_dev->irq, i2c_dev); +err_disable_clk: +clk_disable_unprepare (i2c_dev->bus_clk); +err_put_clk: +clk_rate_exclusive_put (i2c_dev->bus_clk);return ret; }
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 11 lines · Christophe JAILLET
Le 21/05/2022 à 13:46, Wolfram Sang a écrit :
Quoted 10 lines · Miaoqian Lin
Quoted 8 lines
In the error handling path, the
clk_prepare_enable()function call should be balanced by a corresponding 'clk_disable_unprepare()' call. Andclk_set_rate_exclusivecallsclk_rate_exclusive_get(), it should be balanced with call toclk_rate_exclusive_put(). , as already done in the remove function.Fixes bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF")Signed-off-by Miaoqian Lin <[email protected]>
Quoted 7 lines
Quoted 1 line
Looking for a reviewer here, pretty please?
Hi,
on which tree are you working?
A similar patch is already available in -next since several months. (see [1])
Hi,
I mainly work on master, sorry I didn't notice it when submitted.
I may make a mistake with synchronize, thanks for your reply.
Quoted 54 lines
CJ
Quoted 50 lines
Quoted 50 lines
---
drivers/i2c/busses/i2c-bcm2835.c| 21 ++++++++++++++++-----1 file changed, 16 insertions(+), 5 deletions(-)drivers/i2c/busses/i2c-bcm2835.c +10
-5@@ -454,18 +454,21 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret = clk_prepare_enable(i2c_dev->bus_clk); if (ret) { dev_err(&pdev->dev, "Couldn't prepare clock"); - return ret; + goto err_put_clk; } i2c_dev->irq = platform_get_irq(pdev, 0); - if (i2c_dev->irq < 0) - return i2c_dev->irq; + if (i2c_dev->irq < 0) { + ret = i2c_dev->irq; + goto err_disable_clk; + } ret = request_irq(i2c_dev->irq, bcm2835_i2c_isr, IRQF_SHARED, dev_name(&pdev->dev), i2c_dev); if (ret) { dev_err(&pdev->dev, "Could not request IRQ\n"); - return -ENODEV; + ret = -ENODEV; + goto err_disable_clk; } adap = &i2c_dev->adapter;@@ -489,8 +492,16 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ret = i2c_add_adapter(adap); if (ret) - free_irq(i2c_dev->irq, i2c_dev); + goto err_free_irq; + + return ret;+err_free_irq:
+free_irq(i2c_dev->irq, i2c_dev);drivers/i2c/busses/i2c-bcm2835.c +4
-0+err_disable_clk: + clk_disable_unprepare(i2c_dev->bus_clk); +err_put_clk: + clk_rate_exclusive_put(i2c_dev->bus_clk);return ret;
}
--
2.17.1
Quoted 2 lines
on which tree are you working?
Thanks for the heads up!