Skip to contentSkip to conversation

drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:286 __mt76_connac_mcu_alloc_sta_req() error: we previously assumed 'wcid' could be null (see line 281)

PATCH New Dan Carpenter 1 participant 1 message Feb 5, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 33/45 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:286 __mt76_connac_mcu_alloc_sta_req() error: we previously assumed 'wcid' could be null (see line 281)

tree:   https://github.com/nbd168/wireless mt76
head:   9f806d96c7054c92c1e0c0005a16d80e124964b7
commit: cbc8d409f650e3e275059888f766af70a0a0ba51 [33/45] wifi: mt76: connac: set correct muar_idx for mt799x chipsets
config: i386-randconfig-141-20240204 (https://download.01.org/0day-ci/archive/20240204/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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/net/wireless/mediatek/mt76/mt76_connac_mcu.c:286 __mt76_connac_mcu_alloc_sta_req() error: we previously assumed 'wcid' could be null (see line 281)

vim +/wcid +286 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  275  struct sk_buff *
e2c93b68cb5444 Lorenzo Bianconi 2021-12-19  276  __mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
e2c93b68cb5444 Lorenzo Bianconi 2021-12-19  277  				struct mt76_wcid *wcid, int len)
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  278  {
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  279  	struct sta_req_hdr hdr = {
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  280  		.bss_idx = mvif->idx,
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26 @281  		.muar_idx = wcid ? mvif->omac_idx : 0,
                                                                            ^^^^

"wcid" can be NULL

d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  282  		.is_tlv_append = 1,
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  283  	};
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  284  	struct sk_buff *skb;
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  285  
cbc8d409f650e3 Shayne Chen      2024-01-26 @286  	if (is_mt799x(dev) && !wcid->sta)
                                                                               ^^^^^^^^^

Unchecked dereference

cbc8d409f650e3 Shayne Chen      2024-01-26  287  		hdr.muar_idx = 0xe;
cbc8d409f650e3 Shayne Chen      2024-01-26  288  
67aa27431c7f87 Lorenzo Bianconi 2021-01-28  289  	mt76_connac_mcu_get_wlan_idx(dev, wcid, &hdr.wlan_idx_lo,
67aa27431c7f87 Lorenzo Bianconi 2021-01-28  290  				     &hdr.wlan_idx_hi);
e2c93b68cb5444 Lorenzo Bianconi 2021-12-19  291  	skb = mt76_mcu_msg_alloc(dev, NULL, len);
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  292  	if (!skb)
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  293  		return ERR_PTR(-ENOMEM);
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  294  
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  295  	skb_put_data(skb, &hdr, sizeof(hdr));
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  296  
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  297  	return skb;
d0e274af2f2e44 Lorenzo Bianconi 2021-01-26  298  }
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki