From 7068eb65e3d56b45c1f2634f2ba14896522cb0f2 Mon Sep 17 00:00:00 2001
From: Liu Ying <victor.liu@nxp.com>
Date: Wed, 28 Nov 2018 16:27:39 +0800
Subject: [PATCH] MLK-16302-1 drm/imx: dpu: plane: Free dpu_plane when bailout
 from dpu_plane_init

The dpu_plane is allocated with kzalloc() in dpu_plane_init().
In case, dpu_plane_init() fails after that allocation, the bailout path
should free the dpu_plane, otherwise, there will be memory leakage.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
---
 drivers/gpu/drm/imx/dpu/dpu-plane.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/dpu/dpu-plane.c b/drivers/gpu/drm/imx/dpu/dpu-plane.c
index 0a62b003d4733a..c14f9db57c7e4b 100644
--- a/drivers/gpu/drm/imx/dpu/dpu-plane.c
+++ b/drivers/gpu/drm/imx/dpu/dpu-plane.c
@@ -988,8 +988,10 @@ struct dpu_plane *dpu_plane_init(struct drm_device *drm,
 		ret = -EINVAL;
 	}
 
-	if (ret)
+	if (ret) {
+		kfree(dpu_plane);
 		return ERR_PTR(ret);
+	}
 
 	return dpu_plane;
 }
-- 
GitLab