diff mbox series

i2c: imx: don't leak the i2c adapter on error

Message ID 20190329124817.6717-1-laurentiu.tudor@nxp.com (mailing list archive)
State New, archived
Headers show
Series i2c: imx: don't leak the i2c adapter on error | expand

Commit Message

Laurentiu Tudor March 29, 2019, 12:48 p.m. UTC
From: Laurentiu Tudor <laurentiu.tudor@nxp.com>

Make sure to free the i2c adapter on the error exit path.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
---
 drivers/i2c/busses/i2c-imx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Mukesh Ojha March 29, 2019, 1:33 p.m. UTC | #1
On 3/29/2019 6:18 PM, laurentiu.tudor@nxp.com wrote:
> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>
> Make sure to free the i2c adapter on the error exit path.
>
> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

Cheers,
-Mukesh
> ---
>   drivers/i2c/busses/i2c-imx.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 42fed40198a0..2dfd33f48cd8 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1169,11 +1169,13 @@ static int i2c_imx_probe(struct platform_device *pdev)
>   	/* Init DMA config if supported */
>   	ret = i2c_imx_dma_request(i2c_imx, phy_addr);
>   	if (ret < 0)
> -		goto clk_notifier_unregister;
> +		goto del_adapter;
>   
>   	dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
>   	return 0;   /* Return OK */
>   
> +del_adapter:
> +	 i2c_del_adapter(&i2c_imx->adapter);
>   clk_notifier_unregister:
>   	clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
>   rpm_disable:
Uwe Kleine-König March 29, 2019, 9:08 p.m. UTC | #2
On Fri, Mar 29, 2019 at 02:48:17PM +0200, laurentiu.tudor@nxp.com wrote:
> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> 
> Make sure to free the i2c adapter on the error exit path.
> 
> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>

>  drivers/i2c/busses/i2c-imx.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 42fed40198a0..2dfd33f48cd8 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -1169,11 +1169,13 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  	/* Init DMA config if supported */
>  	ret = i2c_imx_dma_request(i2c_imx, phy_addr);
>  	if (ret < 0)
> -		goto clk_notifier_unregister;
> +		goto del_adapter;
>  
>  	dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
>  	return 0;   /* Return OK */
>  
> +del_adapter:
> +	 i2c_del_adapter(&i2c_imx->adapter);

Indention problem here, please remove the superflous space here.

Other than that:

Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fixes: e1ab9a468e3b ("i2c: imx: improve the error handling in i2c_imx_dma_request()")

Thanks
Uwe

>  clk_notifier_unregister:
>  	clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
>  rpm_disable:
> -- 
> 2.17.1
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 42fed40198a0..2dfd33f48cd8 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -1169,11 +1169,13 @@  static int i2c_imx_probe(struct platform_device *pdev)
 	/* Init DMA config if supported */
 	ret = i2c_imx_dma_request(i2c_imx, phy_addr);
 	if (ret < 0)
-		goto clk_notifier_unregister;
+		goto del_adapter;
 
 	dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
 	return 0;   /* Return OK */
 
+del_adapter:
+	 i2c_del_adapter(&i2c_imx->adapter);
 clk_notifier_unregister:
 	clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
 rpm_disable: