drm/rockchip: vop: Fix call to crtc reset helper
authorJonas Karlman <jonas@kwiboo.se>
Wed, 21 Jun 2023 22:33:20 +0000 (22:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:08 +0000 (11:59 +0100)
[ Upstream commit 5aacd290837828c089a83ac9795c74c4c9e2c923 ]

Allocation of crtc_state may fail in vop_crtc_reset, causing an invalid
pointer to be passed to __drm_atomic_helper_crtc_reset.

Fix this by adding a NULL check of crtc_state, similar to other drivers.

Fixes: 01e2eaf40c9d ("drm/rockchip: Convert to using __drm_atomic_helper_crtc_reset() for reset.")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230621223311.2239547-4-jonas@kwiboo.se
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/rockchip/rockchip_drm_vop.c

index 06f647a20fe4440baf95a5a057871210b7f4b13e..41cd12d5f2fa2708030eaafa53bb361fe2420f22 100644 (file)
@@ -1640,7 +1640,10 @@ static void vop_crtc_reset(struct drm_crtc *crtc)
        if (crtc->state)
                vop_crtc_destroy_state(crtc, crtc->state);
 
-       __drm_atomic_helper_crtc_reset(crtc, &crtc_state->base);
+       if (crtc_state)
+               __drm_atomic_helper_crtc_reset(crtc, &crtc_state->base);
+       else
+               __drm_atomic_helper_crtc_reset(crtc, NULL);
 }
 
 #ifdef CONFIG_DRM_ANALOGIX_DP