All of lore.kernel.org
 help / color / mirror / Atom feed
* [chrome-os:chromeos-5.4 182/255] drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c:74 mt7663_usb_sdio_set_rates() warn: variable dereferenced before check 'sta' (see line 70)
@ 2021-05-04  9:33 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-05-04  8:53 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7377 bytes --]

CC: kbuild-all(a)lists.01.org
TO: cros-kernel-buildreports(a)googlegroups.com
TO: Guenter Roeck <groeck@google.com>

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.4
head:   2844d73d89c22c4dddd33272e77e40f50582b1bb
commit: f56036cf6e75afafec0a9b989ef35e0dda25f0a0 [182/255] FROMGIT: mt76: mt7615: fix TSF configuration
:::::: branch date: 2 weeks ago
:::::: commit date: 2 weeks ago
config: i386-randconfig-m021-20210504 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c:74 mt7663_usb_sdio_set_rates() warn: variable dereferenced before check 'sta' (see line 70)

vim +/sta +74 drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c

d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   63  
d1251709841d1d Lorenzo Bianconi 2020-11-08   64  static int mt7663_usb_sdio_set_rates(struct mt7615_dev *dev,
d1251709841d1d Lorenzo Bianconi 2020-11-08   65  				     struct mt7615_wtbl_rate_desc *wrd)
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   66  {
d1251709841d1d Lorenzo Bianconi 2020-11-08   67  	struct mt7615_rate_desc *rate = &wrd->rate;
d1251709841d1d Lorenzo Bianconi 2020-11-08   68  	struct mt7615_sta *sta = wrd->sta;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   69  	u32 w5, w27, addr, val;
f56036cf6e75af Ryder Lee        2021-02-23  @70  	u16 idx = sta->vif->mt76.omac_idx;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   71  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   72  	lockdep_assert_held(&dev->mt76.mutex);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   73  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  @74  	if (!sta)
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   75  		return -EINVAL;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   76  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   77  	if (!mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000))
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   78  		return -ETIMEDOUT;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   79  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   80  	addr = mt7615_mac_wtbl_addr(dev, sta->wcid.idx);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   81  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   82  	w27 = mt76_rr(dev, addr + 27 * 4);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   83  	w27 &= ~MT_WTBL_W27_CC_BW_SEL;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   84  	w27 |= FIELD_PREP(MT_WTBL_W27_CC_BW_SEL, rate->bw);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   85  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   86  	w5 = mt76_rr(dev, addr + 5 * 4);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   87  	w5 &= ~(MT_WTBL_W5_BW_CAP | MT_WTBL_W5_CHANGE_BW_RATE |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   88  		MT_WTBL_W5_MPDU_OK_COUNT |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   89  		MT_WTBL_W5_MPDU_FAIL_COUNT |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   90  		MT_WTBL_W5_RATE_IDX);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   91  	w5 |= FIELD_PREP(MT_WTBL_W5_BW_CAP, rate->bw) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   92  	      FIELD_PREP(MT_WTBL_W5_CHANGE_BW_RATE,
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   93  			 rate->bw_idx ? rate->bw_idx - 1 : 7);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   94  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   95  	mt76_wr(dev, MT_WTBL_RIUCR0, w5);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   96  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   97  	mt76_wr(dev, MT_WTBL_RIUCR1,
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   98  		FIELD_PREP(MT_WTBL_RIUCR1_RATE0, rate->probe_val) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   99  		FIELD_PREP(MT_WTBL_RIUCR1_RATE1, rate->val[0]) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  100  		FIELD_PREP(MT_WTBL_RIUCR1_RATE2_LO, rate->val[1]));
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  101  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  102  	mt76_wr(dev, MT_WTBL_RIUCR2,
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  103  		FIELD_PREP(MT_WTBL_RIUCR2_RATE2_HI, rate->val[1] >> 8) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  104  		FIELD_PREP(MT_WTBL_RIUCR2_RATE3, rate->val[1]) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  105  		FIELD_PREP(MT_WTBL_RIUCR2_RATE4, rate->val[2]) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  106  		FIELD_PREP(MT_WTBL_RIUCR2_RATE5_LO, rate->val[2]));
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  107  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  108  	mt76_wr(dev, MT_WTBL_RIUCR3,
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  109  		FIELD_PREP(MT_WTBL_RIUCR3_RATE5_HI, rate->val[2] >> 4) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  110  		FIELD_PREP(MT_WTBL_RIUCR3_RATE6, rate->val[3]) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  111  		FIELD_PREP(MT_WTBL_RIUCR3_RATE7, rate->val[3]));
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  112  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  113  	mt76_wr(dev, MT_WTBL_UPDATE,
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  114  		FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, sta->wcid.idx) |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  115  		MT_WTBL_UPDATE_RATE_UPDATE |
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  116  		MT_WTBL_UPDATE_TX_COUNT_CLEAR);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  117  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  118  	mt76_wr(dev, addr + 27 * 4, w27);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  119  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  120  	sta->rate_probe = sta->rateset[rate->rateset].probe_rate.idx != -1;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  121  
f56036cf6e75af Ryder Lee        2021-02-23  122  	idx = idx > HW_BSSID_MAX ? HW_BSSID_0 : idx;
f56036cf6e75af Ryder Lee        2021-02-23  123  	addr = idx > 1 ? MT_LPON_TCR2(idx): MT_LPON_TCR0(idx);
f56036cf6e75af Ryder Lee        2021-02-23  124  
f56036cf6e75af Ryder Lee        2021-02-23  125  	mt76_set(dev, addr, MT_LPON_TCR_MODE); /* TSF read */
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  126  	val = mt76_rr(dev, MT_LPON_UTTR0);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  127  	sta->rate_set_tsf = (val & ~BIT(0)) | rate->rateset;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  128  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  129  	if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET))
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  130  		mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  131  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  132  	sta->rate_count = 2 * MT7615_RATE_RETRY * sta->n_rates;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  133  	sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  134  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  135  	return 0;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  136  }
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  137  

:::::: The code at line 74 was first introduced by commit
:::::: d790cea7b38dd2d6a76c55d1547c1c430dd6d431 UPSTREAM: mt76: mt7615: introduce mt7663-usb-sdio-common module

:::::: TO: Lorenzo Bianconi <lorenzo@kernel.org>
:::::: CC: Commit Bot <commit-bot@chromium.org>

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37234 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [chrome-os:chromeos-5.4 182/255] drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c:74 mt7663_usb_sdio_set_rates() warn: variable dereferenced before check 'sta' (see line 70)
@ 2021-05-04  9:33 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-05-04  9:33 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.4
head:   2844d73d89c22c4dddd33272e77e40f50582b1bb
commit: f56036cf6e75afafec0a9b989ef35e0dda25f0a0 [182/255] FROMGIT: mt76: mt7615: fix TSF configuration
config: i386-randconfig-m021-20210504 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c:74 mt7663_usb_sdio_set_rates() warn: variable dereferenced before check 'sta' (see line 70)

vim +/sta +74 drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c

d1251709841d1d Lorenzo Bianconi 2020-11-08   64  static int mt7663_usb_sdio_set_rates(struct mt7615_dev *dev,
d1251709841d1d Lorenzo Bianconi 2020-11-08   65  				     struct mt7615_wtbl_rate_desc *wrd)
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   66  {
d1251709841d1d Lorenzo Bianconi 2020-11-08   67  	struct mt7615_rate_desc *rate = &wrd->rate;
d1251709841d1d Lorenzo Bianconi 2020-11-08   68  	struct mt7615_sta *sta = wrd->sta;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   69  	u32 w5, w27, addr, val;
f56036cf6e75af Ryder Lee        2021-02-23  @70  	u16 idx = sta->vif->mt76.omac_idx;
                                                                  ^^^^^
Patch introduces a new dereference

d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   71  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   72  	lockdep_assert_held(&dev->mt76.mutex);
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   73  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15  @74  	if (!sta)
                                                            ^^^^
Old check is too late.

d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   75  		return -EINVAL;
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   76  
d790cea7b38dd2 Lorenzo Bianconi 2020-07-15   77  	if (!mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000))

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-04  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04  8:53 [chrome-os:chromeos-5.4 182/255] drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c:74 mt7663_usb_sdio_set_rates() warn: variable dereferenced before check 'sta' (see line 70) kernel test robot
2021-05-04  9:33 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.