diff mbox series

[-next] i2c: meson: fix missing clk_disable_unprepare() on error in meson_i2c_probe()

Message ID 20220421090042.2278081-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] i2c: meson: fix missing clk_disable_unprepare() on error in meson_i2c_probe() | expand

Commit Message

Yang Yingliang April 21, 2022, 9 a.m. UTC
Fix the missing clk_disable_unprepare() before return
from meson_i2c_probe() in the error handling case.

Fixes: a57f9b4dd6f5 ("i2c: meson: Use 50% duty cycle for I2C clock")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/i2c/busses/i2c-meson.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Neil Armstrong April 21, 2022, 10:04 a.m. UTC | #1
On 21/04/2022 11:00, Yang Yingliang wrote:
> Fix the missing clk_disable_unprepare() before return
> from meson_i2c_probe() in the error handling case.
> 
> Fixes: a57f9b4dd6f5 ("i2c: meson: Use 50% duty cycle for I2C clock")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>   drivers/i2c/busses/i2c-meson.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c
> index 50dab123380a..195a9716da31 100644
> --- a/drivers/i2c/busses/i2c-meson.c
> +++ b/drivers/i2c/busses/i2c-meson.c
> @@ -520,8 +520,10 @@ static int meson_i2c_probe(struct platform_device *pdev)
>   	meson_i2c_set_mask(i2c, REG_SLAVE_ADDR,
>   			   REG_SLV_SDA_FILTER_MASK | REG_SLV_SCL_FILTER_MASK, 0);
>   
> -	if (!i2c->data->set_clk_div)
> +	if (!i2c->data->set_clk_div) {
> +		clk_disable_unprepare(i2c->clk);
>   		return -EINVAL;
> +	}
>   	i2c->data->set_clk_div(i2c, timings.bus_freq_hz);
>   
>   	ret = i2c_add_adapter(&i2c->adap);

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Wolfram Sang May 4, 2022, 8:38 p.m. UTC | #2
On Thu, Apr 21, 2022 at 05:00:42PM +0800, Yang Yingliang wrote:
> Fix the missing clk_disable_unprepare() before return
> from meson_i2c_probe() in the error handling case.
> 
> Fixes: a57f9b4dd6f5 ("i2c: meson: Use 50% duty cycle for I2C clock")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c
index 50dab123380a..195a9716da31 100644
--- a/drivers/i2c/busses/i2c-meson.c
+++ b/drivers/i2c/busses/i2c-meson.c
@@ -520,8 +520,10 @@  static int meson_i2c_probe(struct platform_device *pdev)
 	meson_i2c_set_mask(i2c, REG_SLAVE_ADDR,
 			   REG_SLV_SDA_FILTER_MASK | REG_SLV_SCL_FILTER_MASK, 0);
 
-	if (!i2c->data->set_clk_div)
+	if (!i2c->data->set_clk_div) {
+		clk_disable_unprepare(i2c->clk);
 		return -EINVAL;
+	}
 	i2c->data->set_clk_div(i2c, timings.bus_freq_hz);
 
 	ret = i2c_add_adapter(&i2c->adap);