Linux-Wireless Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] mt76: mt76s: fix oom in mt76s_tx_queue_skb_raw
@ 2020-07-30  9:38 Lorenzo Bianconi
  2020-08-08 18:34 ` Lorenzo Bianconi
  0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2020-07-30  9:38 UTC (permalink / raw)
  To: nbd; +Cc: lorenzo.bianconi, sean.wang, linux-wireless

Free the mcu skb in case of error in mt76s_tx_queue_skb_raw routine

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/sdio.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/sdio.c b/drivers/net/wireless/mediatek/mt76/sdio.c
index d2b38ed7f3b4..5d8353026aaf 100644
--- a/drivers/net/wireless/mediatek/mt76/sdio.c
+++ b/drivers/net/wireless/mediatek/mt76/sdio.c
@@ -244,22 +244,27 @@ mt76s_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid,
 	struct mt76_queue *q = dev->q_tx[qid].q;
 	int ret = -ENOSPC, len = skb->len;
 
-	spin_lock_bh(&q->lock);
 	if (q->queued == q->ndesc)
-		goto out;
+		goto error;
 
 	ret = mt76_skb_adjust_pad(skb);
 	if (ret)
-		goto out;
+		goto error;
+
+	spin_lock_bh(&q->lock);
 
 	q->entry[q->tail].buf_sz = len;
 	q->entry[q->tail].skb = skb;
 	q->tail = (q->tail + 1) % q->ndesc;
 	q->queued++;
 
-out:
 	spin_unlock_bh(&q->lock);
 
+	return 0;
+
+error:
+	dev_kfree_skb(skb);
+
 	return ret;
 }
 
-- 
2.26.2


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

* Re: [PATCH] mt76: mt76s: fix oom in mt76s_tx_queue_skb_raw
  2020-07-30  9:38 [PATCH] mt76: mt76s: fix oom in mt76s_tx_queue_skb_raw Lorenzo Bianconi
@ 2020-08-08 18:34 ` Lorenzo Bianconi
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Bianconi @ 2020-08-08 18:34 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Felix Fietkau, Sean Wang, linux-wireless

>
> Free the mcu skb in case of error in mt76s_tx_queue_skb_raw routine
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---

I think the proper fixes tag for this patch is:

Fixes: d39b52e31aa6 ("mt76: introduce mt76_sdio module")

Regards,
Lorenzo

>  drivers/net/wireless/mediatek/mt76/sdio.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/sdio.c b/drivers/net/wireless/mediatek/mt76/sdio.c
> index d2b38ed7f3b4..5d8353026aaf 100644
> --- a/drivers/net/wireless/mediatek/mt76/sdio.c
> +++ b/drivers/net/wireless/mediatek/mt76/sdio.c
> @@ -244,22 +244,27 @@ mt76s_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid,
>         struct mt76_queue *q = dev->q_tx[qid].q;
>         int ret = -ENOSPC, len = skb->len;
>
> -       spin_lock_bh(&q->lock);
>         if (q->queued == q->ndesc)
> -               goto out;
> +               goto error;
>
>         ret = mt76_skb_adjust_pad(skb);
>         if (ret)
> -               goto out;
> +               goto error;
> +
> +       spin_lock_bh(&q->lock);
>
>         q->entry[q->tail].buf_sz = len;
>         q->entry[q->tail].skb = skb;
>         q->tail = (q->tail + 1) % q->ndesc;
>         q->queued++;
>
> -out:
>         spin_unlock_bh(&q->lock);
>
> +       return 0;
> +
> +error:
> +       dev_kfree_skb(skb);
> +
>         return ret;
>  }
>
> --
> 2.26.2
>


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30  9:38 [PATCH] mt76: mt76s: fix oom in mt76s_tx_queue_skb_raw Lorenzo Bianconi
2020-08-08 18:34 ` Lorenzo Bianconi

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
	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.git