Linux-Wireless Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ath10k: Correct error check of dma_map_single()
@ 2019-10-10 16:26 Bjorn Andersson
  2019-10-11 11:57 ` Kalle Valo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bjorn Andersson @ 2019-10-10 16:26 UTC (permalink / raw)
  To: Kalle Valo, David S. Miller
  Cc: ath10k, linux-wireless, netdev, linux-kernel, Niklas Cassel, stable

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")
Cc: stable@vger.kernel.org
Reported-by: Niklas Cassel <niklas.cassel@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/net/wireless/ath/ath10k/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 3d2c8fcba952..a01868938692 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -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) {
-- 
2.23.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ath10k: Correct error check of dma_map_single()
  2019-10-10 16:26 [PATCH] ath10k: Correct error check of dma_map_single() Bjorn Andersson
@ 2019-10-11 11:57 ` Kalle Valo
       [not found] ` <20191011115732.044BF60BE8@smtp.codeaurora.org>
  2019-10-11 18:28 ` [PATCH v2] ath10k: Correct error handling " Bjorn Andersson
  2 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2019-10-11 11:57 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: David S. Miller, ath10k, linux-wireless, netdev, linux-kernel,
	Niklas Cassel, stable

Bjorn Andersson <bjorn.andersson@linaro.org> wrote:

> 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")
> Cc: stable@vger.kernel.org
> Reported-by: Niklas Cassel <niklas.cassel@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

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

-- 
https://patchwork.kernel.org/patch/11183923/

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ath10k: Correct error check of dma_map_single()
       [not found] ` <20191011115732.044BF60BE8@smtp.codeaurora.org>
@ 2019-10-11 17:16   ` Bjorn Andersson
  2019-10-14  8:32     ` Kalle Valo
  0 siblings, 1 reply; 6+ messages in thread
From: Bjorn Andersson @ 2019-10-11 17:16 UTC (permalink / raw)
  To: Kalle Valo
  Cc: netdev, linux-wireless, linux-kernel, ath10k, stable,
	Niklas Cassel, David S. Miller

On Fri 11 Oct 04:57 PDT 2019, Kalle Valo wrote:

> Bjorn Andersson <bjorn.andersson@linaro.org> wrote:
> 
> > 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")
> > Cc: stable@vger.kernel.org
> > Reported-by: Niklas Cassel <niklas.cassel@linaro.org>
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> 
> 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

> -- 
> https://patchwork.kernel.org/patch/11183923/
> 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
> 
> 
> _______________________________________________
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] ath10k: Correct error handling of dma_map_single()
  2019-10-10 16:26 [PATCH] ath10k: Correct error check of dma_map_single() Bjorn Andersson
  2019-10-11 11:57 ` Kalle Valo
       [not found] ` <20191011115732.044BF60BE8@smtp.codeaurora.org>
@ 2019-10-11 18:28 ` " Bjorn Andersson
  2019-10-14  8:43   ` Kalle Valo
  2 siblings, 1 reply; 6+ messages in thread
From: Bjorn Andersson @ 2019-10-11 18:28 UTC (permalink / raw)
  To: Kalle Valo, David S. Miller
  Cc: ath10k, linux-wireless, netdev, linux-kernel, Niklas Cassel

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")
Reported-by: Niklas Cassel <niklas.cassel@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v1:
- Free the dequeued skb

 drivers/net/wireless/ath/ath10k/mac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 3d2c8fcba952..e8bdb2ba9b18 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -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",
-- 
2.23.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ath10k: Correct error check of dma_map_single()
  2019-10-11 17:16   ` Bjorn Andersson
@ 2019-10-14  8:32     ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2019-10-14  8:32 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: netdev, linux-wireless, linux-kernel, stable, ath10k,
	Niklas Cassel, David S. Miller

Bjorn Andersson <bjorn.andersson@linaro.org> writes:

> On Fri 11 Oct 04:57 PDT 2019, Kalle Valo wrote:
>
>> Bjorn Andersson <bjorn.andersson@linaro.org> wrote:
>> 
>> > 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")
>> > Cc: stable@vger.kernel.org
>> > Reported-by: Niklas Cassel <niklas.cassel@linaro.org>
>> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
>> 
>> 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.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] ath10k: Correct error handling of dma_map_single()
  2019-10-11 18:28 ` [PATCH v2] ath10k: Correct error handling " Bjorn Andersson
@ 2019-10-14  8:43   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2019-10-14  8:43 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: David S. Miller, ath10k, linux-wireless, netdev, linux-kernel,
	Niklas Cassel

Bjorn Andersson <bjorn.andersson@linaro.org> wrote:

> 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")
> Reported-by: Niklas Cassel <niklas.cassel@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

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

d43810b2c180 ath10k: Correct error handling of dma_map_single()

-- 
https://patchwork.kernel.org/patch/11186173/

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10 16:26 [PATCH] ath10k: Correct error check of dma_map_single() Bjorn Andersson
2019-10-11 11:57 ` Kalle Valo
     [not found] ` <20191011115732.044BF60BE8@smtp.codeaurora.org>
2019-10-11 17:16   ` Bjorn Andersson
2019-10-14  8:32     ` Kalle Valo
2019-10-11 18:28 ` [PATCH v2] ath10k: Correct error handling " Bjorn Andersson
2019-10-14  8:43   ` Kalle Valo

Linux-Wireless Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-wireless/0 linux-wireless/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-wireless linux-wireless/ https://lore.kernel.org/linux-wireless \
		linux-wireless@vger.kernel.org linux-wireless@archiver.kernel.org
	public-inbox-index linux-wireless

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-wireless


AGPL code for this site: git clone https://public-inbox.org/ public-inbox