Skip to contentSkip to conversation

ath10k: Correct error check of dma_map_single()

PATCH Superseded Bjorn Andersson 2 participants 8 messages Oct 10, 2019 – Oct 14, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath10k: Correct error check of dma_map_single()

The return value of dma_map_single() should be checked for errors using dma_mapping_error(), rather than testing for NULL. Correct this.

Fixes 1807da49733e ("ath10k: wmi: add management tx by reference support over wmi")
---
 drivers/net/wireless/ath/ath10k/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/mac.c +1 -1
index 3d2c8fcba952..a01868938692 100644
@@ -3904,7 +3904,7 @@ void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work)
 			     ar->running_fw->fw_file.fw_features)) {
 			paddr = dma_map_single(ar->dev, skb->data,
 					       skb->len, DMA_TO_DEVICE);
-			if (!paddr)
+			if (dma_mapping_error(ar->dev, paddr))
 				continue;
 			ret = ath10k_wmi_mgmt_tx_send(ar, skb, paddr);
 			if (ret) {
Signature · 7 lines
2.23.0


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

The return value of dma_map_single() should be checked for errors using dma_mapping_error(), rather than testing for NULL. Correct this.

Fixes 1807da49733e ("ath10k: wmi: add management tx by reference support over wmi")

Did this fix any real bug? Or is this just something found during code review?

Signature · 9 lines
https://patchwork.kernel.org/patch/11183923/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#2 lore raw
Quoted 5 lines · Kalle Valo
Quoted 3 lines · Bjorn Andersson

The return value of dma_map_single() should be checked for errors using dma_mapping_error(), rather than testing for NULL. Correct this.

Quoted 7 lines
Quoted 4 lines
Fixes 1807da49733e ("ath10k: wmi: add management tx by reference support over wmi")

Did this fix any real bug? Or is this just something found during code review?

CONFIG_DMA_API_DEBUG screamed at us for calling dma_unmap_single() without ever having called dma_mapping_error() on the return value.

But Govind just pointed out to me that I hastily missed the fact that this code path leaks the dequeued skb. So I'll respin the patch to fix both issues at once.

Regards,
Bjorn

Quoted 10 lines
Signature · 9 lines
https://patchwork.kernel.org/patch/11183923/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#3 lore raw
Quoted 13 lines · Bjorn Andersson
Quoted 11 lines · Kalle Valo
Quoted 8 lines · Bjorn Andersson

The return value of dma_map_single() should be checked for errors using dma_mapping_error(), rather than testing for NULL. Correct this.

Fixes 1807da49733e ("ath10k: wmi: add management tx by reference

support over wmi")

Quoted 5 lines
Quoted 2 lines

Did this fix any real bug? Or is this just something found during code review?

CONFIG_DMA_API_DEBUG screamed at us for calling dma_unmap_single() without ever having called dma_mapping_error() on the return value.

Ok, I'll add something about to the commit log in v2 so that the background is also documented.

Signature · 6 lines
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

The return value of dma_map_single() should be checked for errors using dma_mapping_error(), rather than testing for NULL. Correct this.

Fixes 1807da49733e ("ath10k: wmi: add management tx by reference support over wmi")

Did this fix any real bug? Or is this just something found during code review?

Signature · 3 lines
https://patchwork.kernel.org/patch/11183923/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#5 lore raw

PATCH v2 1/1 ath10k: Correct error handling of dma_map_single()

In reply to Bjorn Andersson

The return value of dma_map_single() should be checked for errors using dma_mapping_error() and the skb has been dequeued so it needs to be freed.

Fixes 1807da49733e ("ath10k: wmi: add management tx by reference support over wmi")

---

Changes since v1:
- Free the dequeued skb

 drivers/net/wireless/ath/ath10k/mac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/mac.c +3 -1
index 3d2c8fcba952..e8bdb2ba9b18 100644
@@ -3904,8 +3904,10 @@ void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work)
 			     ar->running_fw->fw_file.fw_features)) {
 			paddr = dma_map_single(ar->dev, skb->data,
 					       skb->len, DMA_TO_DEVICE);
-			if (!paddr)
+			if (dma_mapping_error(ar->dev, paddr)) {
+				ieee80211_free_txskb(ar->hw, skb);
 				continue;
+			}
 			ret = ath10k_wmi_mgmt_tx_send(ar, skb, paddr);
 			if (ret) {
 				ath10k_warn(ar, "failed to transmit management frame by ref via WMI: %d\n",
Signature · 7 lines
2.23.0


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

Re: [PATCH v2] ath10k: Correct error handling of dma_map_single()

Quoted 11 lines · Bjorn Andersson

The return value of dma_map_single() should be checked for errors using dma_mapping_error() and the skb has been dequeued so it needs to be freed.

This was found when enabling CONFIG_DMA_API_DEBUG and it warned about the missing dma_mapping_error() call.

Fixes 1807da49733e ("ath10k: wmi: add management tx by reference support over wmi")

Patch applied to ath-next branch of ath.git, thanks.

d43810b2c180 ath10k: Correct error handling of dma_map_single()

Signature · 3 lines
https://patchwork.kernel.org/patch/11186173/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#7 lore raw

Re: [PATCH v2] ath10k: Correct error handling of dma_map_single()

In reply to Bjorn Andersson
Quoted 11 lines · Bjorn Andersson

The return value of dma_map_single() should be checked for errors using dma_mapping_error() and the skb has been dequeued so it needs to be freed.

This was found when enabling CONFIG_DMA_API_DEBUG and it warned about the missing dma_mapping_error() call.

Fixes 1807da49733e ("ath10k: wmi: add management tx by reference support over wmi")

Patch applied to ath-next branch of ath.git, thanks.

d43810b2c180 ath10k: Correct error handling of dma_map_single()

Signature · 9 lines
https://patchwork.kernel.org/patch/11186173/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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