Re: [PATCH RESEND] drm/msm/dpu: Fix smatch warnings about variable dereferenced before check

From: Rob Clark

Date: Sun Feb 01 2026 - 12:05:15 EST


On Wed, Jan 28, 2026 at 6:50 PM <sunliming@xxxxxxxxx> wrote:
>
> From: sunliming <sunliming@xxxxxxxxxx>
>
> Fix below smatch warnings:
> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c:161 dpu_hw_sspp_setup_pe_config_v13()
> warn: variable dereferenced before check 'ctx' (see line 159)
>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Dan Carpenter <error27@xxxxxxxxx>
> Closes: https://lore.kernel.org/r/202601252214.oEaY3UZM-lkp@xxxxxxxxx/
> Signed-off-by: sunliming <sunliming@xxxxxxxxxx>
> ---
> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c
> index e65f1fc026fd..312ee6597ab1 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c
> @@ -156,11 +156,13 @@ static void dpu_hw_sspp_setup_pe_config_v13(struct dpu_hw_sspp *ctx,
> u8 color;
> u32 lr_pe[4], tb_pe[4];
> const u32 bytemask = 0xff;
> - u32 offset = ctx->cap->sblk->sspp_rec0_blk.base;
> + u32 offset;
>
> if (!ctx || !pe_ext)
> return;
>
> + offset = ctx->cap->sblk->sspp_rec0_blk.base;
> +

btw, in this case (and probably most/all such cases in dpu code that
I've looked at) we should probably just remove the impossible null
checks. (Although the extra indirections in the dpu code make it
harder to see that they are impossible..)

BR,
-R

> c = &ctx->hw;
> /* program SW pixel extension override for all pipes*/
> for (color = 0; color < DPU_MAX_PLANES; color++) {
> --
> 2.25.1
>