drm: arm: malidp: Don't destroy planes manually in error handlers
The top-level error handler calls drm_mode_config_cleanup() which will destroy all planes. There's no need to destroy them manually in lower error handlers. As plane cleanup is now handled entirely by drm_mode_config_cleanup(), we must ensure that the plane .destroy() handler frees allocated memory for the plane object that was freed by malidp_de_planes_destroy(). Do so by replacing the call to devm_kfree() in the .destroy() handler by kfree(). devm_kfree() is currently a no-op as the plane memory is allocated with kzalloc(), not devm_kzalloc(). Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
This commit is contained in:
committed by
Liviu Dudau
parent
d862b2d622
commit
084ffbd7fd
@@ -531,14 +531,13 @@ int malidp_crtc_init(struct drm_device *drm)
|
|||||||
|
|
||||||
if (!primary) {
|
if (!primary) {
|
||||||
DRM_ERROR("no primary plane found\n");
|
DRM_ERROR("no primary plane found\n");
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto crtc_cleanup_planes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = drm_crtc_init_with_planes(drm, &malidp->crtc, primary, NULL,
|
ret = drm_crtc_init_with_planes(drm, &malidp->crtc, primary, NULL,
|
||||||
&malidp_crtc_funcs, NULL);
|
&malidp_crtc_funcs, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto crtc_cleanup_planes;
|
return ret;
|
||||||
|
|
||||||
drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs);
|
drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs);
|
||||||
drm_mode_crtc_set_gamma_size(&malidp->crtc, MALIDP_GAMMA_LUT_SIZE);
|
drm_mode_crtc_set_gamma_size(&malidp->crtc, MALIDP_GAMMA_LUT_SIZE);
|
||||||
@@ -548,9 +547,4 @@ int malidp_crtc_init(struct drm_device *drm)
|
|||||||
malidp_se_set_enh_coeffs(malidp->dev);
|
malidp_se_set_enh_coeffs(malidp->dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
crtc_cleanup_planes:
|
|
||||||
malidp_de_planes_destroy(drm);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,7 +278,6 @@ static int malidp_init(struct drm_device *drm)
|
|||||||
|
|
||||||
static void malidp_fini(struct drm_device *drm)
|
static void malidp_fini(struct drm_device *drm)
|
||||||
{
|
{
|
||||||
malidp_de_planes_destroy(drm);
|
|
||||||
drm_mode_config_cleanup(drm);
|
drm_mode_config_cleanup(drm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ struct malidp_crtc_state {
|
|||||||
#define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base)
|
#define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base)
|
||||||
|
|
||||||
int malidp_de_planes_init(struct drm_device *drm);
|
int malidp_de_planes_init(struct drm_device *drm);
|
||||||
void malidp_de_planes_destroy(struct drm_device *drm);
|
|
||||||
int malidp_crtc_init(struct drm_device *drm);
|
int malidp_crtc_init(struct drm_device *drm);
|
||||||
|
|
||||||
/* often used combination of rotational bits */
|
/* often used combination of rotational bits */
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ static void malidp_de_plane_destroy(struct drm_plane *plane)
|
|||||||
|
|
||||||
drm_plane_helper_disable(plane);
|
drm_plane_helper_disable(plane);
|
||||||
drm_plane_cleanup(plane);
|
drm_plane_cleanup(plane);
|
||||||
devm_kfree(plane->dev->dev, mp);
|
kfree(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -449,18 +449,7 @@ int malidp_de_planes_init(struct drm_device *drm)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
malidp_de_planes_destroy(drm);
|
|
||||||
kfree(formats);
|
kfree(formats);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void malidp_de_planes_destroy(struct drm_device *drm)
|
|
||||||
{
|
|
||||||
struct drm_plane *p, *pt;
|
|
||||||
|
|
||||||
list_for_each_entry_safe(p, pt, &drm->mode_config.plane_list, head) {
|
|
||||||
drm_plane_cleanup(p);
|
|
||||||
kfree(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user