Skip to content

Commit

Permalink
drm/fsl-dcu: avoid memory leak on errors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Agner committed Feb 26, 2016
1 parent e291d29 commit 72cc05a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, NULL);
if (ret < 0)
if (ret) {
primary->funcs->destroy(primary);
return ret;
}

drm_crtc_helper_add(crtc, &fsl_dcu_drm_crtc_helper_funcs);

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,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 = {
Expand Down

0 comments on commit 72cc05a

Please sign in to comment.