Skip to contentSkip to conversation

wifi: rtw89: wow: Add unlock mutex before to return

PATCH In review Alessandro Zanni 2 participants 2 messages Oct 1, 2024 – Oct 4, 2024 Realtek wireless driver (rtw89)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtw89: wow: Add unlock mutex before to return

In error handling code for "ieee80211_gtk_rekey_add failed", release the mutex before to return.

Found with Coccinelle static analisys tool,
script: https://coccinelle.gitlabpages.inria.fr/website/rules/mut.cocci

---
 drivers/net/wireless/realtek/rtw89/wow.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtw89/wow.c +1 -0
index 86e24e07780d..8045acb27cf9 100644
@@ -624,6 +624,7 @@ static struct ieee80211_key_conf *rtw89_wow_gtk_rekey(struct rtw89_dev *rtwdev,
 	kfree(rekey_conf);
 	if (IS_ERR(key)) {
 		rtw89_err(rtwdev, "ieee80211_gtk_rekey_add failed\n");
+		mutex_unlock(&rtwdev->mutex);
 		return NULL;
 	}
 
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 16 lines · Alessandro Zanni

In error handling code for "ieee80211_gtk_rekey_add failed", release the mutex before to return.

Found with Coccinelle static analisys tool,
script: https://coccinelle.gitlabpages.inria.fr/website/rules/mut.cocci

---
 drivers/net/wireless/realtek/rtw89/wow.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtw89/wow.c +0 -0
index 86e24e07780d..8045acb27cf9 100644

drivers/net/wireless/realtek/rtw89/wow.c static struct ieee80211_key_conf *rtw89_wow_gtk_rekey(struct rtw89_dev *rtwdev, · line 629

Quoted 6 lines
drivers/net/wireless/realtek/rtw89/wow.c +1 -0
@@ -624,6 +624,7 @@ static struct ieee80211_key_conf *rtw89_wow_gtk_rekey(struct rtw89_dev *rtwdev,
        kfree(rekey_conf);
        if (IS_ERR(key)) {
                rtw89_err(rtwdev, "ieee80211_gtk_rekey_add failed\n");
+               mutex_unlock(&rtwdev->mutex);
                return NULL;
        }

The driver mutex is held across this function. Only unlock before calling ieee80211_gtk_rekey_add() and lock after that, because the function enters driver again and lock mutex again causing deadlock.

Thus this Coccinelle finding is false alarm. NACK this patch.