[PATCH RFC 28/33] wifi: mt76: mt7925: Fix a locking bug in an error path

Bart Van Assche posted 33 patches 10 months, 1 week ago
[PATCH RFC 28/33] wifi: mt76: mt7925: Fix a locking bug in an error path
Posted by Bart Van Assche 10 months, 1 week ago
Call mt792x_mutex_release() before returning.

This bug has been detected by the Clang thread-safety checker.

Cc: Charles Han <hanchunchao@inspur.com>
Cc: Felix Fietkau <nbd@nbd.name>
Fixes: 5cd0bd815c8a ("wifi: mt76: mt7925: fix NULL deref check in mt7925_change_vif_links")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/net/wireless/mediatek/mt76/mt7925/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 98daf80ac131..40e898f24628 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1992,8 +1992,10 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 					     GFP_KERNEL);
 			mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink),
 					     GFP_KERNEL);
-			if (!mconf || !mlink)
-				return -ENOMEM;
+			if (!mconf || !mlink) {
+				err = -ENOMEM;
+				goto free;
+			}
 		}
 
 		mconfs[link_id] = mconf;