drm/msm/dpu: Add check for cstate
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Tue, 6 Dec 2022 08:05:17 +0000 (16:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:24 +0000 (09:39 +0100)
[ Upstream commit c96988b7d99327bb08bd9efd29a203b22cd88ace ]

As kzalloc may fail and return NULL pointer,
it should be better to check cstate
in order to avoid the NULL pointer dereference
in __drm_atomic_helper_crtc_reset.

Fixes: 1cff7440a86e ("drm/msm: Convert to using __drm_atomic_helper_crtc_reset() for reset.")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/514163/
Link: https://lore.kernel.org/r/20221206080517.43786-1-jiasheng@iscas.ac.cn
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c

index 2186fc947e5b5bf3e058c57defca3a7e4f252865..c76305beff6e54c0a45a5c67c09737056e452813 100644 (file)
@@ -770,7 +770,10 @@ static void dpu_crtc_reset(struct drm_crtc *crtc)
        if (crtc->state)
                dpu_crtc_destroy_state(crtc, crtc->state);
 
-       __drm_atomic_helper_crtc_reset(crtc, &cstate->base);
+       if (cstate)
+               __drm_atomic_helper_crtc_reset(crtc, &cstate->base);
+       else
+               __drm_atomic_helper_crtc_reset(crtc, NULL);
 }
 
 /**