lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202206190637.iURVxsik-lkp@intel.com>
Date:   Mon, 20 Jun 2022 12:00:16 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Abhinav Kumar <quic_abhinavk@...cinc.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org,
        Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
Subject: drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:261
 dpu_encoder_phys_wb_atomic_check() warn: variable dereferenced before check
 'conn_state' (see line 255)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   4b35035bcf80ddb47c0112c4fbd84a63a2836a18
commit: d7d0e73f7de33a2b9998b607707a3e944ef3b86d drm/msm/dpu: introduce the dpu_encoder_phys_* for writeback
config: ia64-randconfig-m031-20220616 (https://download.01.org/0day-ci/archive/20220619/202206190637.iURVxsik-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

New smatch warnings:
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:261 dpu_encoder_phys_wb_atomic_check() warn: variable dereferenced before check 'conn_state' (see line 255)

Old smatch warnings:
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:252 dpu_encoder_phys_wb_atomic_check() error: potentially dereferencing uninitialized 'mode'.

vim +/conn_state +261 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c

d7d0e73f7de33a Abhinav Kumar 2022-04-26  244  static int dpu_encoder_phys_wb_atomic_check(
d7d0e73f7de33a Abhinav Kumar 2022-04-26  245  		struct dpu_encoder_phys *phys_enc,
d7d0e73f7de33a Abhinav Kumar 2022-04-26  246  		struct drm_crtc_state *crtc_state,
d7d0e73f7de33a Abhinav Kumar 2022-04-26  247  		struct drm_connector_state *conn_state)
d7d0e73f7de33a Abhinav Kumar 2022-04-26  248  {
d7d0e73f7de33a Abhinav Kumar 2022-04-26  249  	struct drm_framebuffer *fb;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  250  	const struct drm_display_mode *mode;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  251  
d7d0e73f7de33a Abhinav Kumar 2022-04-26  252  	DPU_DEBUG("[atomic_check:%d, \"%s\",%d,%d]\n",
d7d0e73f7de33a Abhinav Kumar 2022-04-26  253  			phys_enc->wb_idx, mode->name, mode->hdisplay, mode->vdisplay);
d7d0e73f7de33a Abhinav Kumar 2022-04-26  254  
d7d0e73f7de33a Abhinav Kumar 2022-04-26 @255  	if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
                                                     ^^^^^^^^^^^^                  ^^^^^^^^^^^^
Dereferences

d7d0e73f7de33a Abhinav Kumar 2022-04-26  256  		return 0;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  257  
d7d0e73f7de33a Abhinav Kumar 2022-04-26  258  	fb = conn_state->writeback_job->fb;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  259  	mode = &crtc_state->mode;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  260  
d7d0e73f7de33a Abhinav Kumar 2022-04-26 @261  	if (!conn_state || !conn_state->connector) {
                                                    ^^^^^^^^^^^
Checked too late

d7d0e73f7de33a Abhinav Kumar 2022-04-26  262  		DPU_ERROR("invalid connector state\n");
d7d0e73f7de33a Abhinav Kumar 2022-04-26  263  		return -EINVAL;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  264  	} else if (conn_state->connector->status !=
d7d0e73f7de33a Abhinav Kumar 2022-04-26  265  			connector_status_connected) {
d7d0e73f7de33a Abhinav Kumar 2022-04-26  266  		DPU_ERROR("connector not connected %d\n",
d7d0e73f7de33a Abhinav Kumar 2022-04-26  267  				conn_state->connector->status);
d7d0e73f7de33a Abhinav Kumar 2022-04-26  268  		return -EINVAL;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  269  	}
d7d0e73f7de33a Abhinav Kumar 2022-04-26  270  
d7d0e73f7de33a Abhinav Kumar 2022-04-26  271  	DPU_DEBUG("[fb_id:%u][fb:%u,%u]\n", fb->base.id,
d7d0e73f7de33a Abhinav Kumar 2022-04-26  272  			fb->width, fb->height);
d7d0e73f7de33a Abhinav Kumar 2022-04-26  273  
d7d0e73f7de33a Abhinav Kumar 2022-04-26  274  	if (fb->width != mode->hdisplay) {
d7d0e73f7de33a Abhinav Kumar 2022-04-26  275  		DPU_ERROR("invalid fb w=%d, mode w=%d\n", fb->width,
d7d0e73f7de33a Abhinav Kumar 2022-04-26  276  				mode->hdisplay);
d7d0e73f7de33a Abhinav Kumar 2022-04-26  277  		return -EINVAL;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  278  	} else if (fb->height != mode->vdisplay) {
d7d0e73f7de33a Abhinav Kumar 2022-04-26  279  		DPU_ERROR("invalid fb h=%d, mode h=%d\n", fb->height,
d7d0e73f7de33a Abhinav Kumar 2022-04-26  280  				  mode->vdisplay);
d7d0e73f7de33a Abhinav Kumar 2022-04-26  281  		return -EINVAL;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  282  	} else if (fb->width > DEFAULT_MAX_WRITEBACK_WIDTH) {
d7d0e73f7de33a Abhinav Kumar 2022-04-26  283  		DPU_ERROR("invalid fb w=%d, maxlinewidth=%u\n",
d7d0e73f7de33a Abhinav Kumar 2022-04-26  284  				  fb->width, DEFAULT_MAX_WRITEBACK_WIDTH);
d7d0e73f7de33a Abhinav Kumar 2022-04-26  285  		return -EINVAL;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  286  	}
d7d0e73f7de33a Abhinav Kumar 2022-04-26  287  
d7d0e73f7de33a Abhinav Kumar 2022-04-26  288  	return 0;
d7d0e73f7de33a Abhinav Kumar 2022-04-26  289  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ