Skip to contentSkip to conversation

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)

PATCH kernel test robot 2 participants 2 messages Jan 25 – Feb 2

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
TO: Yuanjie Yang <[email protected]>
CC: Dmitry Baryshkov <[email protected]>
CC: Yongxing Mou <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   ca3a02fda4da8e2c1cb6baee5d72352e9e2cfaea
commit: 688c7734002a1ee6f50a28ba9bd7aa380edbe12d [7732/9539] drm/msm/dpu: Add Kaanapali SSPP sub-block support

:::::: branch date: 2 days ago
:::::: commit date: 5 days ago
config: mips-randconfig-r071-20260125 (https://download.01.org/0day-ci/archive/20260125/[email protected]/config)
compiler: mips64-linux-gcc (GCC) 15.2.0
smatch version: v0.5.0-8994-gd50c5a4c

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

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)

vim +/ctx +161 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c

688c7734002a1e Yuanjie Yang 2026-01-15  151  
688c7734002a1e Yuanjie Yang 2026-01-15  152  static void dpu_hw_sspp_setup_pe_config_v13(struct dpu_hw_sspp *ctx,
688c7734002a1e Yuanjie Yang 2026-01-15  153  					    struct dpu_hw_pixel_ext *pe_ext)
688c7734002a1e Yuanjie Yang 2026-01-15  154  {
688c7734002a1e Yuanjie Yang 2026-01-15  155  	struct dpu_hw_blk_reg_map *c;
688c7734002a1e Yuanjie Yang 2026-01-15  156  	u8 color;
688c7734002a1e Yuanjie Yang 2026-01-15  157  	u32 lr_pe[4], tb_pe[4];
688c7734002a1e Yuanjie Yang 2026-01-15  158  	const u32 bytemask = 0xff;
688c7734002a1e Yuanjie Yang 2026-01-15 @159  	u32 offset = ctx->cap->sblk->sspp_rec0_blk.base;
688c7734002a1e Yuanjie Yang 2026-01-15  160  
688c7734002a1e Yuanjie Yang 2026-01-15 @161  	if (!ctx || !pe_ext)
688c7734002a1e Yuanjie Yang 2026-01-15  162  		return;
688c7734002a1e Yuanjie Yang 2026-01-15  163  
688c7734002a1e Yuanjie Yang 2026-01-15  164  	c = &ctx->hw;
688c7734002a1e Yuanjie Yang 2026-01-15  165  	/* program SW pixel extension override for all pipes*/
688c7734002a1e Yuanjie Yang 2026-01-15  166  	for (color = 0; color < DPU_MAX_PLANES; color++) {
688c7734002a1e Yuanjie Yang 2026-01-15  167  		/* color 2 has the same set of registers as color 1 */
688c7734002a1e Yuanjie Yang 2026-01-15  168  		if (color == 2)
688c7734002a1e Yuanjie Yang 2026-01-15  169  			continue;
688c7734002a1e Yuanjie Yang 2026-01-15  170  
688c7734002a1e Yuanjie Yang 2026-01-15  171  		lr_pe[color] = ((pe_ext->right_ftch[color] & bytemask) << 24) |
688c7734002a1e Yuanjie Yang 2026-01-15  172  			       ((pe_ext->right_rpt[color] & bytemask) << 16) |
688c7734002a1e Yuanjie Yang 2026-01-15  173  			       ((pe_ext->left_ftch[color] & bytemask) << 8) |
688c7734002a1e Yuanjie Yang 2026-01-15  174  			       (pe_ext->left_rpt[color] & bytemask);
688c7734002a1e Yuanjie Yang 2026-01-15  175  
688c7734002a1e Yuanjie Yang 2026-01-15  176  		tb_pe[color] = ((pe_ext->btm_ftch[color] & bytemask) << 24) |
688c7734002a1e Yuanjie Yang 2026-01-15  177  			       ((pe_ext->btm_rpt[color] & bytemask) << 16) |
688c7734002a1e Yuanjie Yang 2026-01-15  178  			       ((pe_ext->top_ftch[color] & bytemask) << 8) |
688c7734002a1e Yuanjie Yang 2026-01-15  179  			       (pe_ext->top_rpt[color] & bytemask);
688c7734002a1e Yuanjie Yang 2026-01-15  180  	}
688c7734002a1e Yuanjie Yang 2026-01-15  181  
688c7734002a1e Yuanjie Yang 2026-01-15  182  	/* color 0 */
688c7734002a1e Yuanjie Yang 2026-01-15  183  	DPU_REG_WRITE(c, SSPP_REC_SW_PIX_EXT_LR + offset, lr_pe[0]);
688c7734002a1e Yuanjie Yang 2026-01-15  184  	DPU_REG_WRITE(c, SSPP_REC_SW_PIX_EXT_TB + offset, tb_pe[0]);
688c7734002a1e Yuanjie Yang 2026-01-15  185  
688c7734002a1e Yuanjie Yang 2026-01-15  186  	/* color 1 and color 2 */
688c7734002a1e Yuanjie Yang 2026-01-15  187  	DPU_REG_WRITE(c, SSPP_REC_SW_PIX_EXT_LR_ODX + offset, lr_pe[1]);
688c7734002a1e Yuanjie Yang 2026-01-15  188  	DPU_REG_WRITE(c, SSPP_REC_SW_PIX_EXT_TB_ODX + offset, tb_pe[1]);
688c7734002a1e Yuanjie Yang 2026-01-15  189  }
688c7734002a1e Yuanjie Yang 2026-01-15  190  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 27 lines · Dan Carpenter
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   ca3a02fda4da8e2c1cb6baee5d72352e9e2cfaea
commit: 688c7734002a1ee6f50a28ba9bd7aa380edbe12d [7732/9539] drm/msm/dpu: Add Kaanapali SSPP sub-block support
config: mips-randconfig-r071-20260125 (https://download.01.org/0day-ci/archive/20260125/[email protected]/config)
compiler: mips64-linux-gcc (GCC) 15.2.0
smatch version: v0.5.0-8994-gd50c5a4c

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

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)

vim +/ctx +161 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c

688c7734002a1e Yuanjie Yang 2026-01-15  152  static void dpu_hw_sspp_setup_pe_config_v13(struct dpu_hw_sspp *ctx,
688c7734002a1e Yuanjie Yang 2026-01-15  153  					    struct dpu_hw_pixel_ext *pe_ext)
688c7734002a1e Yuanjie Yang 2026-01-15  154  {
688c7734002a1e Yuanjie Yang 2026-01-15  155  	struct dpu_hw_blk_reg_map *c;
688c7734002a1e Yuanjie Yang 2026-01-15  156  	u8 color;
688c7734002a1e Yuanjie Yang 2026-01-15  157  	u32 lr_pe[4], tb_pe[4];
688c7734002a1e Yuanjie Yang 2026-01-15  158  	const u32 bytemask = 0xff;
688c7734002a1e Yuanjie Yang 2026-01-15 @159  	u32 offset = ctx->cap->sblk->sspp_rec0_blk.base;
                                                             ^^^^^
Quoted 6 lines

Dereference

688c7734002a1e Yuanjie Yang 2026-01-15 160
688c7734002a1e Yuanjie Yang 2026-01-15 @161 if (!ctx || !pe_ext)

                                                     ^^^

NULL check is too late.

Ok, will fix it in a new patch.

Thanks,
Yuanjie

Quoted 10 lines
688c7734002a1e Yuanjie Yang 2026-01-15  162  		return;
688c7734002a1e Yuanjie Yang 2026-01-15  163  
688c7734002a1e Yuanjie Yang 2026-01-15  164  	c = &ctx->hw;
688c7734002a1e Yuanjie Yang 2026-01-15  165  	/* program SW pixel extension override for all pipes*/
688c7734002a1e Yuanjie Yang 2026-01-15  166  	for (color = 0; color < DPU_MAX_PLANES; color++) {
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki