diff mbox

[2/5] drm/imx: ipuv3 crtc: Cleanup ipu planes in ipu_crtc_init() when necessary

Message ID 1448007251-25591-2-git-send-email-Ying.Liu@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liu Ying Nov. 20, 2015, 8:14 a.m. UTC
To avoid memory leakage, we need to cleanup the initialized ipu planes in
the bailout path of ipu_crtc_init().

Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
---
This patch applies to the imx-drm/fixes branch of Philipp Zabel's open git.

 drivers/gpu/drm/imx/ipuv3-crtc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Philipp Zabel Nov. 23, 2015, 11:48 a.m. UTC | #1
Am Freitag, den 20.11.2015, 16:14 +0800 schrieb Liu Ying:
> To avoid memory leakage, we need to cleanup the initialized ipu planes in
> the bailout path of ipu_crtc_init().
> 
> Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
> ---
> This patch applies to the imx-drm/fixes branch of Philipp Zabel's open git.
> 
>  drivers/gpu/drm/imx/ipuv3-crtc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
> index 67813ca..59f44df 100644
> --- a/drivers/gpu/drm/imx/ipuv3-crtc.c
> +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
> @@ -371,7 +371,7 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
>  			ipu_crtc->dev->of_node);
>  	if (ret) {
>  		dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret);
> -		goto err_put_resources;
> +		goto err_cleanup_plane0;
>  	}
>  
>  	ret = ipu_plane_get_resources(ipu_crtc->plane[0]);
> @@ -402,9 +402,14 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
>  	return 0;
>  
>  err_put_plane_res:
> +	if (ipu_crtc->plane[1])
> +		ipu_plane_cleanup(ipu_crtc->plane[1]);
> +
>  	ipu_plane_put_resources(ipu_crtc->plane[0]);
>  err_remove_crtc:
>  	imx_drm_remove_crtc(ipu_crtc->imx_crtc);
> +err_cleanup_plane0:
> +	ipu_plane_cleanup(ipu_crtc->plane[0]);
>  err_put_resources:
>  	ipu_put_resources(ipu_crtc);

I think we can use ipu_plane_destroy as-is instead of
ipu_plane_put_resources + ipu_plane_cleanup.

regards
Philipp
diff mbox

Patch

diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index 67813ca..59f44df 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -371,7 +371,7 @@  static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
 			ipu_crtc->dev->of_node);
 	if (ret) {
 		dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret);
-		goto err_put_resources;
+		goto err_cleanup_plane0;
 	}
 
 	ret = ipu_plane_get_resources(ipu_crtc->plane[0]);
@@ -402,9 +402,14 @@  static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
 	return 0;
 
 err_put_plane_res:
+	if (ipu_crtc->plane[1])
+		ipu_plane_cleanup(ipu_crtc->plane[1]);
+
 	ipu_plane_put_resources(ipu_crtc->plane[0]);
 err_remove_crtc:
 	imx_drm_remove_crtc(ipu_crtc->imx_crtc);
+err_cleanup_plane0:
+	ipu_plane_cleanup(ipu_crtc->plane[0]);
 err_put_resources:
 	ipu_put_resources(ipu_crtc);