[drm-tip:drm-tip 1117/1129] drivers/gpu/drm/drm_atomic_uapi.c:342 drm_atomic_set_crtc_for_connector() error: we previously assumed 'crtc' could be null (see line 326)

Dan Carpenter dan.carpenter at oracle.com
Mon Nov 16 09:33:40 UTC 2020


tree:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
head:   af383973ac39069d9ffcac0287a896a107005d54
commit: e3aae683e861a987d3d7dca593aaff93ac001bcb [1117/1129] drm: convert drm_atomic_uapi.c to new debug helpers
config: i386-randconfig-m021-20201115 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>

smatch warnings:
drivers/gpu/drm/drm_atomic_uapi.c:342 drm_atomic_set_crtc_for_connector() error: we previously assumed 'crtc' could be null (see line 326)

vim +/crtc +342 drivers/gpu/drm/drm_atomic_uapi.c

72fdb40c1a4b48f Daniel Vetter  2018-09-05  305  int
72fdb40c1a4b48f Daniel Vetter  2018-09-05  306  drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
72fdb40c1a4b48f Daniel Vetter  2018-09-05  307  				  struct drm_crtc *crtc)
72fdb40c1a4b48f Daniel Vetter  2018-09-05  308  {
72fdb40c1a4b48f Daniel Vetter  2018-09-05  309  	struct drm_connector *connector = conn_state->connector;
72fdb40c1a4b48f Daniel Vetter  2018-09-05  310  	struct drm_crtc_state *crtc_state;
72fdb40c1a4b48f Daniel Vetter  2018-09-05  311  
72fdb40c1a4b48f Daniel Vetter  2018-09-05  312  	if (conn_state->crtc == crtc)
72fdb40c1a4b48f Daniel Vetter  2018-09-05  313  		return 0;
72fdb40c1a4b48f Daniel Vetter  2018-09-05  314  
72fdb40c1a4b48f Daniel Vetter  2018-09-05  315  	if (conn_state->crtc) {
72fdb40c1a4b48f Daniel Vetter  2018-09-05  316  		crtc_state = drm_atomic_get_new_crtc_state(conn_state->state,
72fdb40c1a4b48f Daniel Vetter  2018-09-05  317  							   conn_state->crtc);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  318  
72fdb40c1a4b48f Daniel Vetter  2018-09-05  319  		crtc_state->connector_mask &=
72fdb40c1a4b48f Daniel Vetter  2018-09-05  320  			~drm_connector_mask(conn_state->connector);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  321  
72fdb40c1a4b48f Daniel Vetter  2018-09-05  322  		drm_connector_put(conn_state->connector);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  323  		conn_state->crtc = NULL;
72fdb40c1a4b48f Daniel Vetter  2018-09-05  324  	}
72fdb40c1a4b48f Daniel Vetter  2018-09-05  325  
72fdb40c1a4b48f Daniel Vetter  2018-09-05 @326  	if (crtc) {
                                                            ^^^^
If "crtc" is NULL the error message will crash

72fdb40c1a4b48f Daniel Vetter  2018-09-05  327  		crtc_state = drm_atomic_get_crtc_state(conn_state->state, crtc);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  328  		if (IS_ERR(crtc_state))
72fdb40c1a4b48f Daniel Vetter  2018-09-05  329  			return PTR_ERR(crtc_state);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  330  
72fdb40c1a4b48f Daniel Vetter  2018-09-05  331  		crtc_state->connector_mask |=
72fdb40c1a4b48f Daniel Vetter  2018-09-05  332  			drm_connector_mask(conn_state->connector);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  333  
72fdb40c1a4b48f Daniel Vetter  2018-09-05  334  		drm_connector_get(conn_state->connector);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  335  		conn_state->crtc = crtc;
72fdb40c1a4b48f Daniel Vetter  2018-09-05  336  
e3aae683e861a98 Simon Ser      2020-11-11  337  		drm_dbg_atomic(crtc->dev,
e3aae683e861a98 Simon Ser      2020-11-11  338  			       "Link [CONNECTOR:%d:%s] state %p to [CRTC:%d:%s]\n",
72fdb40c1a4b48f Daniel Vetter  2018-09-05  339  			       connector->base.id, connector->name,
72fdb40c1a4b48f Daniel Vetter  2018-09-05  340  			       conn_state, crtc->base.id, crtc->name);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  341  	} else {
e3aae683e861a98 Simon Ser      2020-11-11 @342  		drm_dbg_atomic(crtc->dev,
                                                                               ^^^^^^^^^
BOOM!

e3aae683e861a98 Simon Ser      2020-11-11  343  			       "Link [CONNECTOR:%d:%s] state %p to [NOCRTC]\n",
72fdb40c1a4b48f Daniel Vetter  2018-09-05  344  			       connector->base.id, connector->name,
72fdb40c1a4b48f Daniel Vetter  2018-09-05  345  			       conn_state);
72fdb40c1a4b48f Daniel Vetter  2018-09-05  346  	}
72fdb40c1a4b48f Daniel Vetter  2018-09-05  347  
72fdb40c1a4b48f Daniel Vetter  2018-09-05  348  	return 0;
72fdb40c1a4b48f Daniel Vetter  2018-09-05  349  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 46141 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20201116/8a9dbd66/attachment-0001.gz>


More information about the dri-devel mailing list