[PATCH 5.10 052/142] mt76: mt7663s: fix rx buffer refcounting

Greg Kroah-Hartman
2021-02-02T13:52:20Z

From: Lorenzo Bianconi <lorenzo@kernel.org>

commit 952de419b6179ad1424f512d52ec7122662fdf63 upstream.

Similar to mt7601u driver, fix erroneous rx page refcounting

Fixes: a66cbdd6573d ("mt76: mt7615: introduce mt7663s support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/dca19c9d445156201bc41f7cbb6e894bbc9a678c.1610644945.git.lorenzo@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

--- a/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c
@@ -85,7 +85,7 @@ static int mt7663s_rx_run_queue(struct m
{
struct mt76_queue *q = &dev->q_rx[qid];
struct mt76_sdio *sdio = &dev->sdio;
- int len = 0, err, i, order;
+ int len = 0, err, i;
struct page *page;
u8 *buf;

@@ -98,8 +98,7 @@ static int mt7663s_rx_run_queue(struct m
if (len > sdio->func->cur_blksize)
len = roundup(len, sdio->func->cur_blksize);

- order = get_order(len);
- page = __dev_alloc_pages(GFP_KERNEL, order);
+ page = __dev_alloc_pages(GFP_KERNEL, get_order(len));
if (!page)
return -ENOMEM;

@@ -111,7 +110,7 @@ static int mt7663s_rx_run_queue(struct m

if (err < 0) {
dev_err(dev->dev, "sdio read data failed:%d\n", err);
- __free_pages(page, order);
+ put_page(page);
return err;
}

@@ -128,7 +127,7 @@ static int mt7663s_rx_run_queue(struct m
if (q->queued + i + 1 == q->ndesc)
break;
}
- __free_pages(page, order);
+ put_page(page);

spin_lock_bh(&q->lock);
q->head = (q->head + i) % q->ndesc;