]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/msm/dpu: Add check for pstates
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Tue, 6 Dec 2022 08:02:36 +0000 (16:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:43:45 +0000 (16:43 +0100)
[ Upstream commit 93340e10b9c5fc86730d149636e0aa8b47bb5a34 ]

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

Fixes: 19c2c6078363 ("drm/msm: Add SDM845 DPU support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/514160/
Link: https://lore.kernel.org/r/20221206080236.43687-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 d61c3855670dd2554131615f4b8a06c9fa933772..2e28db60f4d2f3e117564fbccd13d4fa9afad1d3 100644 (file)
@@ -836,6 +836,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
        }
 
        pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
+       if (!pstates)
+               return -ENOMEM;
 
        dpu_crtc = to_dpu_crtc(crtc);
        cstate = to_dpu_crtc_state(state);