From: Miaoqian Lin <linmq006@gmail.com> To: Florian Fainelli <f.fainelli@gmail.com>, Ray Jui <rjui@broadcom.com>, Scott Branden <sbranden@broadcom.com>, bcm-kernel-feedback-list@broadcom.com, Nicolas Saenz Julienne <nsaenz@kernel.org>, Wolfram Sang <wsa@kernel.org>, Stefan Wahren <stefan.wahren@i2se.com>, Miaoqian Lin <linmq006@gmail.com>, Eric Anholt <eric@anholt.net>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>, Annaliese McDermond <nh6z@nh6z.net>, linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: bcm2835: Fix error handling in bcm2835_i2c_probe Date: Sun, 3 Apr 2022 06:33:08 +0000 [thread overview] Message-ID: <20220403063310.7525-1-linmq006@gmail.com> (raw) 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. Fixes: bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> --- drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index 5149454eef4a..d794448866a7 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -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; } -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Miaoqian Lin <linmq006@gmail.com> To: Florian Fainelli <f.fainelli@gmail.com>, Ray Jui <rjui@broadcom.com>, Scott Branden <sbranden@broadcom.com>, bcm-kernel-feedback-list@broadcom.com, Nicolas Saenz Julienne <nsaenz@kernel.org>, Wolfram Sang <wsa@kernel.org>, Stefan Wahren <stefan.wahren@i2se.com>, Miaoqian Lin <linmq006@gmail.com>, Eric Anholt <eric@anholt.net>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>, Annaliese McDermond <nh6z@nh6z.net>, linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: bcm2835: Fix error handling in bcm2835_i2c_probe Date: Sun, 3 Apr 2022 06:33:08 +0000 [thread overview] Message-ID: <20220403063310.7525-1-linmq006@gmail.com> (raw) 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. Fixes: bebff81fb8b9 ("i2c: bcm2835: Model Divider in CCF") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> --- drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index 5149454eef4a..d794448866a7 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -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; } -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-04-03 6:33 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-03 6:33 Miaoqian Lin [this message] 2022-04-03 6:33 ` [PATCH] i2c: bcm2835: Fix error handling in bcm2835_i2c_probe Miaoqian Lin 2022-05-21 11:46 ` Wolfram Sang 2022-05-21 11:46 ` Wolfram Sang 2022-05-21 12:28 ` Christophe JAILLET 2022-05-21 12:28 ` Christophe JAILLET 2022-05-21 13:56 ` Miaoqian Lin 2022-05-21 13:56 ` Miaoqian Lin 2022-05-22 21:01 ` Wolfram Sang 2022-05-22 21: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=20220403063310.7525-1-linmq006@gmail.com \ --to=linmq006@gmail.com \ --cc=bcm-kernel-feedback-list@broadcom.com \ --cc=eric@anholt.net \ --cc=f.fainelli@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-i2c@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-rpi-kernel@lists.infradead.org \ --cc=nh6z@nh6z.net \ --cc=nsaenz@kernel.org \ --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \ --cc=rjui@broadcom.com \ --cc=sbranden@broadcom.com \ --cc=stefan.wahren@i2se.com \ --cc=wsa@kernel.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.