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: <202106041339.3wpPAETC-lkp@intel.com>
Date:   Fri, 4 Jun 2021 10:10:22 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org,
        Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org
Subject: drivers/thunderbolt/test.c:266 alloc_dev_default() error: we
 previously assumed 'port->dual_link_port' could be null (see line 258)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f88cd3fb9df228e5ce4e13ec3dbad671ddb2146e
commit: 54509f5005caccd8459c9084535802feeb27bb2c thunderbolt: Add KUnit tests for path walking
config: i386-randconfig-m021-20210604 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

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

smatch warnings:
drivers/thunderbolt/test.c:266 alloc_dev_default() error: we previously assumed 'port->dual_link_port' could be null (see line 258)
drivers/thunderbolt/test.c:268 alloc_dev_default() error: we previously assumed 'upstream_port->dual_link_port' could be null (see line 258)

vim +266 drivers/thunderbolt/test.c

54509f5005cacc Mika Westerberg 2020-04-29  144  static struct tb_switch *alloc_dev_default(struct kunit *test,
54509f5005cacc Mika Westerberg 2020-04-29  145  					   struct tb_switch *parent,
54509f5005cacc Mika Westerberg 2020-04-29  146  					   u64 route, bool bonded)
54509f5005cacc Mika Westerberg 2020-04-29  147  {
54509f5005cacc Mika Westerberg 2020-04-29  148  	struct tb_port *port, *upstream_port;
54509f5005cacc Mika Westerberg 2020-04-29  149  	struct tb_switch *sw;
54509f5005cacc Mika Westerberg 2020-04-29  150  
54509f5005cacc Mika Westerberg 2020-04-29  151  	sw = alloc_switch(test, route, 1, 19);
54509f5005cacc Mika Westerberg 2020-04-29  152  	if (!sw)
54509f5005cacc Mika Westerberg 2020-04-29  153  		return NULL;
54509f5005cacc Mika Westerberg 2020-04-29  154  
54509f5005cacc Mika Westerberg 2020-04-29  155  	sw->config.vendor_id = 0x8086;
54509f5005cacc Mika Westerberg 2020-04-29  156  	sw->config.device_id = 0x15ef;
54509f5005cacc Mika Westerberg 2020-04-29  157  
54509f5005cacc Mika Westerberg 2020-04-29  158  	sw->ports[0].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  159  	sw->ports[0].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  160  	sw->ports[0].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  161  
54509f5005cacc Mika Westerberg 2020-04-29  162  	sw->ports[1].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  163  	sw->ports[1].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  164  	sw->ports[1].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  165  	sw->ports[1].dual_link_port = &sw->ports[2];
54509f5005cacc Mika Westerberg 2020-04-29  166  
54509f5005cacc Mika Westerberg 2020-04-29  167  	sw->ports[2].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  168  	sw->ports[2].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  169  	sw->ports[2].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  170  	sw->ports[2].dual_link_port = &sw->ports[1];
54509f5005cacc Mika Westerberg 2020-04-29  171  	sw->ports[2].link_nr = 1;
54509f5005cacc Mika Westerberg 2020-04-29  172  
54509f5005cacc Mika Westerberg 2020-04-29  173  	sw->ports[3].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  174  	sw->ports[3].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  175  	sw->ports[3].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  176  	sw->ports[3].dual_link_port = &sw->ports[4];
54509f5005cacc Mika Westerberg 2020-04-29  177  
54509f5005cacc Mika Westerberg 2020-04-29  178  	sw->ports[4].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  179  	sw->ports[4].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  180  	sw->ports[4].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  181  	sw->ports[4].dual_link_port = &sw->ports[3];
54509f5005cacc Mika Westerberg 2020-04-29  182  	sw->ports[4].link_nr = 1;
54509f5005cacc Mika Westerberg 2020-04-29  183  
54509f5005cacc Mika Westerberg 2020-04-29  184  	sw->ports[5].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  185  	sw->ports[5].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  186  	sw->ports[5].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  187  	sw->ports[5].dual_link_port = &sw->ports[6];
54509f5005cacc Mika Westerberg 2020-04-29  188  
54509f5005cacc Mika Westerberg 2020-04-29  189  	sw->ports[6].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  190  	sw->ports[6].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  191  	sw->ports[6].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  192  	sw->ports[6].dual_link_port = &sw->ports[5];
54509f5005cacc Mika Westerberg 2020-04-29  193  	sw->ports[6].link_nr = 1;
54509f5005cacc Mika Westerberg 2020-04-29  194  
54509f5005cacc Mika Westerberg 2020-04-29  195  	sw->ports[7].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  196  	sw->ports[7].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  197  	sw->ports[7].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  198  	sw->ports[7].dual_link_port = &sw->ports[8];
54509f5005cacc Mika Westerberg 2020-04-29  199  
54509f5005cacc Mika Westerberg 2020-04-29  200  	sw->ports[8].config.type = TB_TYPE_PORT;
54509f5005cacc Mika Westerberg 2020-04-29  201  	sw->ports[8].config.max_in_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  202  	sw->ports[8].config.max_out_hop_id = 19;
54509f5005cacc Mika Westerberg 2020-04-29  203  	sw->ports[8].dual_link_port = &sw->ports[7];
54509f5005cacc Mika Westerberg 2020-04-29  204  	sw->ports[8].link_nr = 1;
54509f5005cacc Mika Westerberg 2020-04-29  205  
54509f5005cacc Mika Westerberg 2020-04-29  206  	sw->ports[9].config.type = TB_TYPE_PCIE_UP;
54509f5005cacc Mika Westerberg 2020-04-29  207  	sw->ports[9].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  208  	sw->ports[9].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  209  
54509f5005cacc Mika Westerberg 2020-04-29  210  	sw->ports[10].config.type = TB_TYPE_PCIE_DOWN;
54509f5005cacc Mika Westerberg 2020-04-29  211  	sw->ports[10].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  212  	sw->ports[10].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  213  
54509f5005cacc Mika Westerberg 2020-04-29  214  	sw->ports[11].config.type = TB_TYPE_PCIE_DOWN;
54509f5005cacc Mika Westerberg 2020-04-29  215  	sw->ports[11].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  216  	sw->ports[11].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  217  
54509f5005cacc Mika Westerberg 2020-04-29  218  	sw->ports[12].config.type = TB_TYPE_PCIE_DOWN;
54509f5005cacc Mika Westerberg 2020-04-29  219  	sw->ports[12].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  220  	sw->ports[12].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  221  
54509f5005cacc Mika Westerberg 2020-04-29  222  	sw->ports[13].config.type = TB_TYPE_DP_HDMI_OUT;
54509f5005cacc Mika Westerberg 2020-04-29  223  	sw->ports[13].config.max_in_hop_id = 9;
54509f5005cacc Mika Westerberg 2020-04-29  224  	sw->ports[13].config.max_out_hop_id = 9;
54509f5005cacc Mika Westerberg 2020-04-29  225  	sw->ports[13].cap_adap = -1;
54509f5005cacc Mika Westerberg 2020-04-29  226  
54509f5005cacc Mika Westerberg 2020-04-29  227  	sw->ports[14].config.type = TB_TYPE_DP_HDMI_OUT;
54509f5005cacc Mika Westerberg 2020-04-29  228  	sw->ports[14].config.max_in_hop_id = 9;
54509f5005cacc Mika Westerberg 2020-04-29  229  	sw->ports[14].config.max_out_hop_id = 9;
54509f5005cacc Mika Westerberg 2020-04-29  230  	sw->ports[14].cap_adap = -1;
54509f5005cacc Mika Westerberg 2020-04-29  231  
54509f5005cacc Mika Westerberg 2020-04-29  232  	sw->ports[15].disabled = true;
54509f5005cacc Mika Westerberg 2020-04-29  233  
54509f5005cacc Mika Westerberg 2020-04-29  234  	sw->ports[16].config.type = TB_TYPE_USB3_UP;
54509f5005cacc Mika Westerberg 2020-04-29  235  	sw->ports[16].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  236  	sw->ports[16].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  237  
54509f5005cacc Mika Westerberg 2020-04-29  238  	sw->ports[17].config.type = TB_TYPE_USB3_DOWN;
54509f5005cacc Mika Westerberg 2020-04-29  239  	sw->ports[17].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  240  	sw->ports[17].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  241  
54509f5005cacc Mika Westerberg 2020-04-29  242  	sw->ports[18].config.type = TB_TYPE_USB3_DOWN;
54509f5005cacc Mika Westerberg 2020-04-29  243  	sw->ports[18].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  244  	sw->ports[18].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  245  
54509f5005cacc Mika Westerberg 2020-04-29  246  	sw->ports[19].config.type = TB_TYPE_USB3_DOWN;
54509f5005cacc Mika Westerberg 2020-04-29  247  	sw->ports[19].config.max_in_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  248  	sw->ports[19].config.max_out_hop_id = 8;
54509f5005cacc Mika Westerberg 2020-04-29  249  
54509f5005cacc Mika Westerberg 2020-04-29  250  	if (!parent)
54509f5005cacc Mika Westerberg 2020-04-29  251  		return sw;
54509f5005cacc Mika Westerberg 2020-04-29  252  
54509f5005cacc Mika Westerberg 2020-04-29  253  	/* Link them */
54509f5005cacc Mika Westerberg 2020-04-29  254  	upstream_port = tb_upstream_port(sw);
54509f5005cacc Mika Westerberg 2020-04-29  255  	port = tb_port_at(route, parent);
54509f5005cacc Mika Westerberg 2020-04-29  256  	port->remote = upstream_port;
54509f5005cacc Mika Westerberg 2020-04-29  257  	upstream_port->remote = port;
54509f5005cacc Mika Westerberg 2020-04-29 @258  	if (port->dual_link_port && upstream_port->dual_link_port) {
                                                            ^^^^^^^^^^^^^^^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Checks for NULL

54509f5005cacc Mika Westerberg 2020-04-29  259  		port->dual_link_port->remote = upstream_port->dual_link_port;
54509f5005cacc Mika Westerberg 2020-04-29  260  		upstream_port->dual_link_port->remote = port->dual_link_port;
54509f5005cacc Mika Westerberg 2020-04-29  261  	}
54509f5005cacc Mika Westerberg 2020-04-29  262  
54509f5005cacc Mika Westerberg 2020-04-29  263  	if (bonded) {
54509f5005cacc Mika Westerberg 2020-04-29  264  		/* Bonding is used */
54509f5005cacc Mika Westerberg 2020-04-29  265  		port->bonded = true;
54509f5005cacc Mika Westerberg 2020-04-29 @266  		port->dual_link_port->bonded = true;
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unchecked dereference

54509f5005cacc Mika Westerberg 2020-04-29  267  		upstream_port->bonded = true;
54509f5005cacc Mika Westerberg 2020-04-29 @268  		upstream_port->dual_link_port->bonded = true;
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It's possible that these warning would go away if we were running
Smatch with the cross function database.  (I'm not sure how the zero
day bot does it).

54509f5005cacc Mika Westerberg 2020-04-29  269  	}
54509f5005cacc Mika Westerberg 2020-04-29  270  
54509f5005cacc Mika Westerberg 2020-04-29  271  	return sw;
54509f5005cacc Mika Westerberg 2020-04-29  272  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ