Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1272766

[PATCH 3/7] drm/fsl-dcu: avoid memory leak on errors

From Stefan Agner <stefan@agner.ch>
Newsgroups linux.kernel
Subject [PATCH 3/7] drm/fsl-dcu: avoid memory leak on errors
Date 2015-11-19 03:50 +0100
Message-ID <qwnsm-3hD-19@gated-at.bofh.it> (permalink)
References <qwnsl-3hD-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Improve error handling during CRTC initialization. Especially avoid
memory leaks in the primary plane initialization error path.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c  | 7 ++++++-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
index adf9212..b2f56e4 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
@@ -143,10 +143,15 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
 	int ret;
 
 	primary = fsl_dcu_drm_primary_create_plane(fsl_dev->drm);
+	if (!primary)
+		return -ENOMEM;
+
 	ret = drm_crtc_init_with_planes(fsl_dev->drm, crtc, primary, NULL,
 					&fsl_dcu_drm_crtc_funcs);
-	if (ret < 0)
+	if (ret) {
+		primary->funcs->destroy(primary);
 		return ret;
+	}
 
 	drm_crtc_helper_add(crtc, &fsl_dcu_drm_crtc_helper_funcs);
 
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
index 92e606a..1cb6295 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
@@ -184,6 +184,7 @@ static const struct drm_plane_helper_funcs fsl_dcu_drm_plane_helper_funcs = {
 static void fsl_dcu_drm_plane_destroy(struct drm_plane *plane)
 {
 	drm_plane_cleanup(plane);
+	kfree(plane);
 }
 
 static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] drm/fsl-dcu: fixes and enhancements Stefan Agner <stefan@agner.ch> - 2015-11-19 03:50 +0100
  [PATCH 5/7] drm/fsl-dcu: mask all interrupts on initialization Stefan Agner <stefan@agner.ch> - 2015-11-19 03:50 +0100
  [PATCH 1/7] drm/fsl-dcu: specify volatile registers Stefan Agner <stefan@agner.ch> - 2015-11-19 03:50 +0100
  [PATCH 6/7] drm/fsl-dcu: fix alpha blending Stefan Agner <stefan@agner.ch> - 2015-11-19 03:50 +0100
  [PATCH 2/7] drm/fsl-dcu: remove regmap return value checks Stefan Agner <stefan@agner.ch> - 2015-11-19 03:50 +0100
  [PATCH 3/7] drm/fsl-dcu: avoid memory leak on errors Stefan Agner <stefan@agner.ch> - 2015-11-19 03:50 +0100

csiph-web