]> git.proxmox.com Git - mirror_ubuntu-kernels.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)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 24 Jan 2023 08:24:41 +0000 (10:24 +0200)
As kzalloc may fail and return NULL pointer,
it should be better to check pstates
in order to avoid the NULL pointer dereference.

Fixes: 25fdd5933e4c ("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>
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c

index 175d2557e43cf52e1963e24b5013ee7a08959a0e..f29a339a3705062de4cbcd57c9f0cb3d3fa1524f 100644 (file)
@@ -1153,6 +1153,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
        bool needs_dirtyfb = dpu_crtc_needs_dirtyfb(crtc_state);
 
        pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
+       if (!pstates)
+               return -ENOMEM;
 
        if (!crtc_state->enable || !crtc_state->active) {
                DRM_DEBUG_ATOMIC("crtc%d -> enable %d, active %d, skip atomic_check\n",