Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fe73d46 authored by Russell King's avatar Russell King Committed by Greg Kroah-Hartman
Browse files

imx-drm: imx-drm-core: make imx_drm_crtc_register() safer



imx_drm_crtc_register() doesn't clean up the CRTC upon failure, which
leaves the CRTC attached to the DRM device.  Also, it does setup after
attaching the CRTC to the DRM device.

Fix this by reordering the function such that we do the setup before
drm_crtc_init(): this fixes both issues.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Acked-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 942325c8
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -377,8 +377,6 @@ static int imx_drm_crtc_register(struct imx_drm_crtc *imx_drm_crtc)
	struct imx_drm_device *imxdrm = __imx_drm_device();
	int ret;

	drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc,
			imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs);
	ret = drm_mode_crtc_set_gamma_size(imx_drm_crtc->crtc, 256);
	if (ret)
		return ret;
@@ -386,6 +384,9 @@ static int imx_drm_crtc_register(struct imx_drm_crtc *imx_drm_crtc)
	drm_crtc_helper_add(imx_drm_crtc->crtc,
			imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);

	drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc,
			imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs);

	drm_mode_group_reinit(imxdrm->drm);

	return 0;