wifi: ath12k: fix issues when unbinding
Subsystems (2)
v4 cover wifi: ath12k: fix issues when unbinding
wifi: ath12k: fix issues when unbinding
Currently, ath12k driver is not working from VMs but it cannot be unbinded either from there. I would like to send these patches to fix the issues that I have found in order to get the unbind operation working there, at least to fix the errors found during the process when the initial error is detected.
Just FYI and out of the scope of these patches, I am unbinding and binding to apply a workaround with an extra module to fix the MSI addressing by means of kprobes to be able to work with this device from VMs.
PATCH v4 1/2 wifi: ath12k: fix crash when unbinding
If there is an error during some initialization related to firmware, the function ath12k_dp_cc_cleanup is called to release resources. However this is released again when the device is unbinded (ath12k_pci), and we get:
BUG: kernel NULL pointer dereference, address: 0000000000000020 at RIP: 0010:ath12k_dp_cc_cleanup.part.0+0xb6/0x500 [ath12k] Call Trace:
ath12k_dp_cc_cleanupath12k_dp_freeath12k_core_deinitath12k_pci_remove
...
The issue is always reproducible from a VM because the MSI addressing initialization is failing.
In order to fix the issue, just set to NULL the released structure in ath12k_dp_cc_cleanup at the end.
---
v4:
- Send with cover letter to get reference with 2/2
v3: https://lore.kernel.org/linux-wireless/[email protected]/
v2: https://lore.kernel.org/linux-wireless/[email protected]/
v1: https://lore.kernel.org/linux-wireless/[email protected]/
drivers/net/wireless/ath/ath12k/dp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath12k/dp.c +1 -0
@@ -1241,6 +1241,7 @@ static void ath12k_dp_cc_cleanup(struct ath12k_base *ab) }kfree (dp->spt_info); + dp->spt_info =NULL ; }static void ath12k_dp_reoq_lut_cleanup (struct ath12k_base *ab)
Signature · 1 line
2.46.2
PATCH v4 2/2 wifi: ath12k: fix warning when unbinding
In reply to Jose Ignacio Tornos MartinezIf there is an error during some initialization related to firmware, the buffers dp->tx_ring[i].tx_status are released.
However this is released again when the device is unbinded (ath12k_pci), and we get:
WARNING: CPU: 0 PID: 2098 at mm/slub.c:4689 free_large_kmalloc+0x4d/0x80 Call Trace:
free_large_kmallocath12k_dp_freeath12k_core_deinitath12k_pci_remove
...
The issue is always reproducible from a VM because the MSI addressing initialization is failing.
In order to fix the issue, just set the buffers to NULL after releasing in order to avoid the double free.
---
v4:
- Send with cover letter to get reference with 1/2
v3: https://lore.kernel.org/linux-wireless/[email protected]/
v2: https://lore.kernel.org/linux-wireless/[email protected]/
v1: https://lore.kernel.org/linux-wireless/[email protected]/
drivers/net/wireless/ath/ath12k/dp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/dp.c +3 -1
@@ -1277,8 +1277,10 @@ void ath12k_dp_free(struct ath12k_base *ab)ath12k_dp_rx_reo_cmd_list_cleanup (ab); -for (i =0 ; i < ab->hw_params->max_tx_ring; i++) +for (i =0 ; i < ab->hw_params->max_tx_ring; i++) {kfree (dp->tx_ring[i].tx_status); + dp->tx_ring[i].tx_status =NULL ; + }ath12k_dp_rx_free (ab);/* Deinit any SOC level resource */
Signature · 1 line
2.47.0
Jeff Johnson
AppliedQuoted 8 lines · Jose Ignacio Tornos Martinez
wifi: ath12k: fix issues when unbinding
Currently, ath12k driver is not working from VMs but it cannot be unbinded either from there. I would like to send these patches to fix the issues that I have found in order to get the unbind operation working there, at least to fix the errors found during the process when the initial error is detected.
[...]
Applied, thanks!
[1/2] wifi: ath12k: fix crash when unbinding
commit: 1304446f67863385dc4c914b6e0194f6664ee764
[2/2] wifi: ath12k: fix warning when unbinding
commit: ca68ce0d9f4bcd032fd1334441175ae399642a06Best regards,
Signature · 1 line
Jeff Johnson <[email protected]>