From: lorenzo@kernel.org
To: nbd@nbd.name
Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com,
lorenzo.bianconi@redhat.com, dan.carpenter@oracle.com,
Lorenzo Bianconi <lorenzo@kernel.org>
Subject: [PATCH] mt76: usb: fix warning in mt76u_buf_free
Date: Thu, 21 Feb 2019 00:57:19 +0100 [thread overview]
Message-ID: <bfd5659680fb3ef89554a48ff950d74dd88240dd.1550706341.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1550706341.git.lorenzo@kernel.org>
From: Lorenzo Bianconi <lorenzo@kernel.org>
Fix following static checker warning in mt76u_buf_free:
drivers/net/wireless/mediatek/mt76/usb.c:372 mt76u_buf_free()
warn: address of 'urb->sg[i]' is non-NULL
There is no need to check sg page pointer since urb->num_sgs
has been already validated in mt76u_fill_rx_sg
Fixes: cb83585e1121 ("mt76: usb: fix possible memory leak in mt76u_buf_free")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/usb.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index cbfddf2ebfeb..ac3da948d43a 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -364,16 +364,11 @@ mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf)
void mt76u_buf_free(struct mt76u_buf *buf)
{
struct urb *urb = buf->urb;
- struct scatterlist *sg;
int i;
- for (i = 0; i < urb->num_sgs; i++) {
- sg = &urb->sg[i];
- if (!sg)
- continue;
+ for (i = 0; i < urb->num_sgs; i++)
+ skb_free_frag(sg_virt(&urb->sg[i]));
- skb_free_frag(sg_virt(sg));
- }
if (buf->buf)
skb_free_frag(buf->buf);
--
2.20.1
next parent reply other threads:[~2019-02-20 23:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1550706341.git.lorenzo@kernel.org>
2019-02-20 23:57 ` lorenzo [this message]
2019-02-21 5:10 ` [PATCH] mt76: usb: fix warning in mt76u_buf_free Kalle Valo
2019-02-21 7:15 ` Lorenzo Bianconi
2019-02-26 9:41 ` Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bfd5659680fb3ef89554a48ff950d74dd88240dd.1550706341.git.lorenzo@kernel.org \
--to=lorenzo@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=sgruszka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox