From: Bo Jiao <[email protected]>
fix potential memory leakage, recycle rxwi when mt76_dma_add_buf() call fails.
Signed-off-by: Bo Jiao <[email protected]>
---
drivers/net/wireless/mediatek/mt76/dma.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index fc24b35..9053344 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -592,6 +592,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
qbuf.len = len - offset;
qbuf.skip_unmap = false;
if (mt76_dma_add_buf(dev, q, &qbuf, 1, 0, buf, t) < 0) {
+ mt76_put_rxwi(dev, t);
dma_unmap_single(dev->dma_dev, addr, len,
DMA_FROM_DEVICE);
skb_free_frag(buf);
--
2.18.0
> From: Bo Jiao <[email protected]>
>
> fix potential memory leakage, recycle rxwi when mt76_dma_add_buf() call fails.
>
> Signed-off-by: Bo Jiao <[email protected]>
> ---
> drivers/net/wireless/mediatek/mt76/dma.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index fc24b35..9053344 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -592,6 +592,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
> qbuf.len = len - offset;
> qbuf.skip_unmap = false;
> if (mt76_dma_add_buf(dev, q, &qbuf, 1, 0, buf, t) < 0) {
> + mt76_put_rxwi(dev, t);
I think we should add it even if page_frag_alloc or dma_map_single fail.
Regards,
Lorenzo
> dma_unmap_single(dev->dma_dev, addr, len,
> DMA_FROM_DEVICE);
> skb_free_frag(buf);
> --
> 2.18.0
>