diff mbox series

[-next] i2c: mpc: drop release for resource allocated with devm_*

Message ID 20210412160026.194423-1-weiyongjun1@huawei.com
State Accepted
Headers show
Series [-next] i2c: mpc: drop release for resource allocated with devm_* | expand

Commit Message

Wei Yongjun April 12, 2021, 4 p.m. UTC
It's not necessary to release resource which allocated with devm_*
and those release may leads to a double free. And also remove useless
irq_dispose_mapping() call since mapping not created.

Fixes: 09aab7add7bf ("i2c: mpc: use device managed APIs")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/i2c/busses/i2c-mpc.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

Chris Packham April 12, 2021, 9:09 p.m. UTC | #1
On 13/04/21 4:00 am, Wei Yongjun wrote:
> It's not necessary to release resource which allocated with devm_*
> and those release may leads to a double free. And also remove useless
> irq_dispose_mapping() call since mapping not created.
>
> Fixes: 09aab7add7bf ("i2c: mpc: use device managed APIs")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Thanks for the fix.

Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

> ---
>   drivers/i2c/busses/i2c-mpc.c | 6 ------
>   1 file changed, 6 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 46cdb36e2f9b..6e5614acebac 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -759,12 +759,6 @@ static int fsl_i2c_remove(struct platform_device *op)
>   	if (i2c->clk_per)
>   		clk_disable_unprepare(i2c->clk_per);
>   
> -	if (i2c->irq)
> -		free_irq(i2c->irq, i2c);
> -
> -	irq_dispose_mapping(i2c->irq);
> -	iounmap(i2c->base);
> -	kfree(i2c);
>   	return 0;
>   };
>   
>
Wolfram Sang April 13, 2021, 12:20 p.m. UTC | #2
On Mon, Apr 12, 2021 at 04:00:26PM +0000, Wei Yongjun wrote:
> It's not necessary to release resource which allocated with devm_*
> and those release may leads to a double free. And also remove useless
> irq_dispose_mapping() call since mapping not created.
> 
> Fixes: 09aab7add7bf ("i2c: mpc: use device managed APIs")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 46cdb36e2f9b..6e5614acebac 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -759,12 +759,6 @@  static int fsl_i2c_remove(struct platform_device *op)
 	if (i2c->clk_per)
 		clk_disable_unprepare(i2c->clk_per);
 
-	if (i2c->irq)
-		free_irq(i2c->irq, i2c);
-
-	irq_dispose_mapping(i2c->irq);
-	iounmap(i2c->base);
-	kfree(i2c);
 	return 0;
 };