mt76: connac: always check return value from mt76_connac_mcu_alloc_wtbl_req
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 12 Feb 2021 11:51:05 +0000 (12:51 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sun, 11 Apr 2021 16:50:38 +0000 (18:50 +0200)
Even if this is not a real bug since mt76_connac_mcu_alloc_wtbl_req routine
can fails just if nskb is NULL , always check return value from
mt76_connac_mcu_alloc_wtbl_req in order to avoid possible future
mistake.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

index 631596f..4ecbd54 100644 (file)
@@ -1040,6 +1040,9 @@ mt7615_mcu_sta_ba(struct mt7615_dev *dev,
 
        wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid,
                                                  WTBL_SET, sta_wtbl, &skb);
+       if (IS_ERR(wtbl_hdr))
+               return PTR_ERR(wtbl_hdr);
+
        mt76_connac_mcu_wtbl_ba_tlv(&dev->mt76, skb, params, enable, tx,
                                    sta_wtbl, wtbl_hdr);
 
index e6ad6cb..ac8d6ad 100644 (file)
@@ -833,6 +833,9 @@ int mt76_connac_mcu_add_sta_cmd(struct mt76_phy *phy,
        wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(dev, wcid,
                                                  WTBL_RESET_AND_SET,
                                                  sta_wtbl, &skb);
+       if (IS_ERR(wtbl_hdr))
+               return PTR_ERR(wtbl_hdr);
+
        if (enable) {
                mt76_connac_mcu_wtbl_generic_tlv(dev, skb, vif, sta, sta_wtbl,
                                                 wtbl_hdr);