Skip to contentSkip to conversation

ath10k: unregister spectral before mac

PATCH Applied Simon Wunderlich 2 participants 5 messages Aug 12, 2014 – Aug 14, 2014 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath10k: unregister spectral before mac

If spectral is unregistered after mac80211, the relayfs file has already been removed recursively by mac/cfg80211, and spectral tries to remove the file once more, thus leading to double free problems. Better clean up spectral before to avoid that problem.

---
 drivers/net/wireless/ath/ath10k/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +6 -2
index d3474b4..ba2e87a 100644
@@ -1043,6 +1043,12 @@ void ath10k_core_unregister(struct ath10k *ar)
 	if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
 		return;
 
+	/* Stop spectral before unregistering from mac80211 to remove the
+	 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
+	 * would be already be free'd recursively, leading to a double free.
+	 */
+	ath10k_spectral_destroy(ar);
+
 	/* We must unregister from mac80211 before we stop HTC and HIF.
 	 * Otherwise we will fail to submit commands to FW and mac80211 will be
 	 * unhappy about callback failures. */
@@ -1050,8 +1056,6 @@ void ath10k_core_unregister(struct ath10k *ar)
 
 	ath10k_core_free_firmware_files(ar);
 
-	ath10k_spectral_destroy(ar);
-
 	ath10k_debug_destroy(ar);
 }
 EXPORT_SYMBOL(ath10k_core_unregister);
Signature · 7 lines
2.1.0.rc1


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#1 lore raw
Quoted 7 lines · Simon Wunderlich

If spectral is unregistered after mac80211, the relayfs file has already been removed recursively by mac/cfg80211, and spectral tries to remove the file once more, thus leading to double free problems. Better clean up spectral before to avoid that problem.

Thanks for checking this. But I'm just wondering why even bother to call relay_close() in the first place if mac80211 recursively removes everything anyway? We don't remove any of the debugfs files anyway.

Signature · 6 lines
Kalle Valo

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#2 lore raw
Quoted 6 lines · On Thursday 14 August 2014 13:12:13 Kalle Valo wrote:
Quoted 5 lines · Simon Wunderlich

If spectral is unregistered after mac80211, the relayfs file has already been removed recursively by mac/cfg80211, and spectral tries to remove the file once more, thus leading to double free problems. Better clean up spectral before to avoid that problem.

Quoted 6 lines
Quoted 2 lines

Thanks for checking this. But I'm just wondering why even bother to call relay_close() in the first place if mac80211 recursively removes everything anyway? We don't remove any of the debugfs files anyway.

We need to relay_close() in any case because this function also causes to clean up internal buffers of relayfs.

An alternative to this patch could be to instead having remove_buf_file_handler() call debugfs_remove() just do nothing and relay on the upper layers to (recursively) remove that file - then, the relayfs stuff still can get cleaned up. But that's also not very elegant either. If you prefer that I can prepare a patch though ....

Cheers,
Simon

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

#3 lore raw
Quoted 14 lines · Simon Wunderlich
Quoted 6 lines · On Thursday 14 August 2014 13:12:13 Kalle Valo wrote:
Quoted 5 lines · Simon Wunderlich

If spectral is unregistered after mac80211, the relayfs file has already been removed recursively by mac/cfg80211, and spectral tries to remove the file once more, thus leading to double free problems. Better clean up spectral before to avoid that problem.

Quoted 6 lines
Quoted 2 lines

Thanks for checking this. But I'm just wondering why even bother to call relay_close() in the first place if mac80211 recursively removes everything anyway? We don't remove any of the debugfs files anyway.

Quoted 8 lines

We need to relay_close() in any case because this function also causes to clean up internal buffers of relayfs.

An alternative to this patch could be to instead having remove_buf_file_handler() call debugfs_remove() just do nothing and relay on the upper layers to (recursively) remove that file - then, the relayfs stuff still can get cleaned up. But that's also not very elegant either. If you prefer that I can prepare a patch though ....

Yeah, that's not really any better. I'll apply your original patch.

Signature · 6 lines
Kalle Valo

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
Applied
#4 lore raw
In reply to Simon Wunderlich
Quoted 7 lines · Simon Wunderlich

If spectral is unregistered after mac80211, the relayfs file has already been removed recursively by mac/cfg80211, and spectral tries to remove the file once more, thus leading to double free problems. Better clean up spectral before to avoid that problem.

Thanks, applied.

Signature · 6 lines
Kalle Valo

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k