Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: brcmfmac: unmap dma buffer in brcmf_msgbuf_alloc_pktid()

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>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221207013114.1748936-1-shaozhengchao@huawei.com

authored by

Zhengchao Shao and committed by
Kalle Valo
b9f42003 212fde3f

+4 -1
+4 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
··· 347 347 count++; 348 348 } while (count < pktids->array_size); 349 349 350 - if (count == pktids->array_size) 350 + if (count == pktids->array_size) { 351 + dma_unmap_single(dev, *physaddr, skb->len - data_offset, 352 + pktids->direction); 351 353 return -ENOMEM; 354 + } 352 355 353 356 array[*idx].data_offset = data_offset; 354 357 array[*idx].physaddr = *physaddr;