]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mt76: mt7996: prevent uninit return in mt7996_mac_sta_add_links
authorQasim Ijaz <qasdev00@gmail.com>
Mon, 21 Apr 2025 11:05:50 +0000 (12:05 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 21 May 2025 12:49:38 +0000 (14:49 +0200)
If link_conf_dereference_protected() or mt7996_vif_link()
or link_sta_dereference_protected() fail the code jumps to
the error_unlink label and returns ret which is uninitialised.

Fix this by setting err before jumping to error_unlink.

Fixes: c7e4fc362443 ("wifi: mt76: mt7996: Update mt7996_mcu_add_sta to MLO support")
Fixes: dd82a9e02c05 ("wifi: mt76: mt7996: Rely on mt7996_sta_link in sta_add/sta_remove callbacks")
Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
Link: https://patch.msgid.link/20250421110550.9839-1-qasdev00@gmail.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7996/main.c

index 91c64e3a0860ff0dc5405627b23f79f4ebd1dafd..70823bbb165c7e2720d1762fa1159ba747a31389 100644 (file)
@@ -998,16 +998,22 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
                        continue;
 
                link_conf = link_conf_dereference_protected(vif, link_id);
-               if (!link_conf)
+               if (!link_conf) {
+                       err = -EINVAL;
                        goto error_unlink;
+               }
 
                link = mt7996_vif_link(dev, vif, link_id);
-               if (!link)
+               if (!link) {
+                       err = -EINVAL;
                        goto error_unlink;
+               }
 
                link_sta = link_sta_dereference_protected(sta, link_id);
-               if (!link_sta)
+               if (!link_sta) {
+                       err = -EINVAL;
                        goto error_unlink;
+               }
 
                err = mt7996_mac_sta_init_link(dev, link_conf, link_sta, link,
                                               link_id);