From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yan-Hsuan Chuang <tony0620emma@gmail.com>,
Po-Hao Huang <phhuang@realtek.com>
Cc: Kalle Valo <kvalo@kernel.org>, Ping-Ke Shih <pkshih@realtek.com>,
linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] rtw88: fix use after free in rtw_hw_scan_update_probe_req()
Date: Wed, 2 Feb 2022 16:05:10 +0300 [thread overview]
Message-ID: <20220202130510.GA27283@kili> (raw)
This code needs to use skb_queue_walk_safe() instead of skb_queue_walk()
because it frees the list iterator.
Fixes: d95984b5580d ("rtw88: fix memory overrun and memory leak during hw_scan")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/net/wireless/realtek/rtw88/fw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
index ce9535cce723..2de0bb67bac6 100644
--- a/drivers/net/wireless/realtek/rtw88/fw.c
+++ b/drivers/net/wireless/realtek/rtw88/fw.c
@@ -1864,7 +1864,7 @@ static int rtw_hw_scan_update_probe_req(struct rtw_dev *rtwdev,
{
struct cfg80211_scan_request *req = rtwvif->scan_req;
struct sk_buff_head list;
- struct sk_buff *skb;
+ struct sk_buff *skb, *tmp;
u8 num = req->n_ssids, i, bands = 0;
int ret;
@@ -1889,7 +1889,7 @@ static int rtw_hw_scan_update_probe_req(struct rtw_dev *rtwdev,
return _rtw_hw_scan_update_probe_req(rtwdev, num * bands, &list);
out:
- skb_queue_walk(&list, skb)
+ skb_queue_walk_safe(&list, skb, tmp)
kfree_skb(skb);
return ret;
--
2.20.1
next reply other threads:[~2022-02-02 13:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 13:05 Dan Carpenter [this message]
2022-02-03 7:59 ` [PATCH] rtw88: fix use after free in rtw_hw_scan_update_probe_req() Pkshih
2022-02-03 8:22 ` Dan Carpenter
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=20220202130510.GA27283@kili \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=phhuang@realtek.com \
--cc=pkshih@realtek.com \
--cc=tony0620emma@gmail.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;
as well as URLs for NNTP newsgroup(s).