diff mbox series

[1/2] media: rkisp1: Fix media device memory leak

Message ID 20231122-rkisp-fixes-v1-1-1958af371e39@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series media: rkisp1: Fix memory leaks | expand

Commit Message

Tomi Valkeinen Nov. 22, 2023, 2:42 p.m. UTC
Add missing calls to media_device_cleanup() to fix memory leak.

Fixes: d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Tommaso Merciai Nov. 22, 2023, 3:12 p.m. UTC | #1
Hi Tomi,

On Wed, Nov 22, 2023 at 04:42:22PM +0200, Tomi Valkeinen wrote:
> Add missing calls to media_device_cleanup() to fix memory leak.
> 
> Fixes: d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> index c41abd2833f1..e10cc2881757 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> @@ -617,6 +617,7 @@ static int rkisp1_probe(struct platform_device *pdev)
>  	media_device_unregister(&rkisp1->media_dev);
>  err_unreg_v4l2_dev:
>  	v4l2_device_unregister(&rkisp1->v4l2_dev);
> +	media_device_cleanup(&rkisp1->media_dev);
>  err_pm_runtime_disable:
>  	pm_runtime_disable(&pdev->dev);
>  	return ret;
> @@ -637,6 +638,8 @@ static void rkisp1_remove(struct platform_device *pdev)
>  	media_device_unregister(&rkisp1->media_dev);
>  	v4l2_device_unregister(&rkisp1->v4l2_dev);
>  
> +	media_device_cleanup(&rkisp1->media_dev);
> +
>  	pm_runtime_disable(&pdev->dev);
>  }

Looks good to me.
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>

Thanks & Regards,
Tommaso

>  
> 
> -- 
> 2.34.1
> 
>
Laurent Pinchart Nov. 22, 2023, 3:42 p.m. UTC | #2
Hi Tomi,

Thank you for the patch.

On Wed, Nov 22, 2023 at 04:42:22PM +0200, Tomi Valkeinen wrote:
> Add missing calls to media_device_cleanup() to fix memory leak.
> 
> Fixes: d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> index c41abd2833f1..e10cc2881757 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> @@ -617,6 +617,7 @@ static int rkisp1_probe(struct platform_device *pdev)
>  	media_device_unregister(&rkisp1->media_dev);
>  err_unreg_v4l2_dev:
>  	v4l2_device_unregister(&rkisp1->v4l2_dev);
> +	media_device_cleanup(&rkisp1->media_dev);

As media_device_cleanup() cleans up for media_device_init(), shouldn't
it go to the err_pm_runtime_disable label ? The label may need to be
renamed to err_media_cleanup then.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  err_pm_runtime_disable:
>  	pm_runtime_disable(&pdev->dev);
>  	return ret;
> @@ -637,6 +638,8 @@ static void rkisp1_remove(struct platform_device *pdev)
>  	media_device_unregister(&rkisp1->media_dev);
>  	v4l2_device_unregister(&rkisp1->v4l2_dev);
>  
> +	media_device_cleanup(&rkisp1->media_dev);
> +
>  	pm_runtime_disable(&pdev->dev);
>  }
>
Tomi Valkeinen Nov. 22, 2023, 3:44 p.m. UTC | #3
On 22/11/2023 17:42, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Wed, Nov 22, 2023 at 04:42:22PM +0200, Tomi Valkeinen wrote:
>> Add missing calls to media_device_cleanup() to fix memory leak.
>>
>> Fixes: d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> ---
>>   drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
>> index c41abd2833f1..e10cc2881757 100644
>> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
>> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
>> @@ -617,6 +617,7 @@ static int rkisp1_probe(struct platform_device *pdev)
>>   	media_device_unregister(&rkisp1->media_dev);
>>   err_unreg_v4l2_dev:
>>   	v4l2_device_unregister(&rkisp1->v4l2_dev);
>> +	media_device_cleanup(&rkisp1->media_dev);
> 
> As media_device_cleanup() cleans up for media_device_init(), shouldn't
> it go to the err_pm_runtime_disable label ? The label may need to be
> renamed to err_media_cleanup then.

Oops, you're right. I'll fix that.

  Tomi

> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>>   err_pm_runtime_disable:
>>   	pm_runtime_disable(&pdev->dev);
>>   	return ret;
>> @@ -637,6 +638,8 @@ static void rkisp1_remove(struct platform_device *pdev)
>>   	media_device_unregister(&rkisp1->media_dev);
>>   	v4l2_device_unregister(&rkisp1->v4l2_dev);
>>   
>> +	media_device_cleanup(&rkisp1->media_dev);
>> +
>>   	pm_runtime_disable(&pdev->dev);
>>   }
>>   
>
diff mbox series

Patch

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
index c41abd2833f1..e10cc2881757 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
@@ -617,6 +617,7 @@  static int rkisp1_probe(struct platform_device *pdev)
 	media_device_unregister(&rkisp1->media_dev);
 err_unreg_v4l2_dev:
 	v4l2_device_unregister(&rkisp1->v4l2_dev);
+	media_device_cleanup(&rkisp1->media_dev);
 err_pm_runtime_disable:
 	pm_runtime_disable(&pdev->dev);
 	return ret;
@@ -637,6 +638,8 @@  static void rkisp1_remove(struct platform_device *pdev)
 	media_device_unregister(&rkisp1->media_dev);
 	v4l2_device_unregister(&rkisp1->v4l2_dev);
 
+	media_device_cleanup(&rkisp1->media_dev);
+
 	pm_runtime_disable(&pdev->dev);
 }