[PATCH v2] drm/gma500: fix memory leaks

Wenwen Wang wenwen at cs.uga.edu
Mon Aug 19 03:34:30 UTC 2019


In mdfld_dsi_output_init(), if an error occurs, the execution is directed
to 'dsi_init_err0' or 'dsi_init_err1'. However, in some cases, some
previously allocated buffers and resources are not deallocated, leading to
memory/resource leaks. To fix this issue, revise the labels.

Signed-off-by: Wenwen Wang <wenwen at cs.uga.edu>
---
 drivers/gpu/drm/gma500/mdfld_dsi_output.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.c b/drivers/gpu/drm/gma500/mdfld_dsi_output.c
index 03023fa..0cf4121 100644
--- a/drivers/gpu/drm/gma500/mdfld_dsi_output.c
+++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.c
@@ -573,13 +573,13 @@ void mdfld_dsi_output_init(struct drm_device *dev,
 	if (mdfld_dsi_pkg_sender_init(dsi_connector, pipe)) {
 		DRM_ERROR("Package Sender initialization failed on pipe %d\n",
 									pipe);
-		goto dsi_init_err0;
+		goto dsi_init_err1;
 	}
 
 	encoder = mdfld_dsi_dpi_init(dev, dsi_connector, p_vid_funcs);
 	if (!encoder) {
 		DRM_ERROR("Create DPI encoder failed\n");
-		goto dsi_init_err1;
+		goto dsi_init_err2;
 	}
 	encoder->private = dsi_config;
 	dsi_config->encoder = encoder;
@@ -589,14 +589,13 @@ void mdfld_dsi_output_init(struct drm_device *dev,
 	return;
 
 	/*TODO: add code to destroy outputs on error*/
-dsi_init_err1:
+dsi_init_err2:
 	/*destroy sender*/
 	mdfld_dsi_pkg_sender_destroy(dsi_connector->pkg_sender);
-
+dsi_init_err1:
 	drm_connector_cleanup(connector);
-
+dsi_init_err0:
 	kfree(dsi_config->fixed_mode);
 	kfree(dsi_config);
-dsi_init_err0:
 	kfree(dsi_connector);
 }
-- 
2.7.4



More information about the dri-devel mailing list