netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: brcmfmac: unmap dma buffer in brcmf_msgbuf_alloc_pktid()
@ 2022-12-07  1:31 Zhengchao Shao
  2022-12-21 18:33 ` Kalle Valo
  2022-12-22 16:10 ` Kalle Valo
  0 siblings, 2 replies; 9+ messages in thread
From: Zhengchao Shao @ 2022-12-07  1:31 UTC (permalink / raw)
  To: netdev, linux-wireless, brcm80211-dev-list.pdl,
	SHA-cyfmac-dev-list, kvalo, davem, edumazet, kuba, pabeni,
	bigeasy
  Cc: aspriel, franky.lin, hante.meuleman, wright.feng, chi-hsien.lin,
	a.fatoum, alsi, pieterpg, dekim, linville, weiyongjun1,
	yuehaibing, shaozhengchao

After the DMA buffer is mapped to a physical address, address is stored
in pktids in brcmf_msgbuf_alloc_pktid(). Then, pktids is parsed in
brcmf_msgbuf_get_pktid()/brcmf_msgbuf_release_array() to obtain physaddr
and later unmap the DMA buffer. But when count is always equal to
pktids->array_size, physaddr isn't stored in pktids and the DMA buffer
will not be unmapped anyway.

Fixes: 9a1bb60250d2 ("brcmfmac: Adding msgbuf protocol.")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
index cec53f934940..45fbcbdc7d9e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
@@ -347,8 +347,11 @@ brcmf_msgbuf_alloc_pktid(struct device *dev,
 		count++;
 	} while (count < pktids->array_size);
 
-	if (count == pktids->array_size)
+	if (count == pktids->array_size) {
+		dma_unmap_single(dev, *physaddr, skb->len - data_offset,
+				 pktids->direction);
 		return -ENOMEM;
+	}
 
 	array[*idx].data_offset = data_offset;
 	array[*idx].physaddr = *physaddr;
-- 
2.34.1


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

end of thread, other threads:[~2022-12-22 16:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-07  1:31 [PATCH] wifi: brcmfmac: unmap dma buffer in brcmf_msgbuf_alloc_pktid() Zhengchao Shao
2022-12-21 18:33 ` Kalle Valo
2022-12-22  7:38   ` Sebastian Andrzej Siewior
2022-12-22  8:46     ` Kalle Valo
2022-12-22  8:52       ` shaozhengchao
2022-12-22 10:59         ` Arend van Spriel
2022-12-22 11:35           ` shaozhengchao
2022-12-22 11:37             ` Arend van Spriel
2022-12-22 16:10 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).