From: Zong-Zhe Yang <kevin_yang@realtek.com>
To: Zilin Guan <zilin@seu.edu.cn>, Ping-Ke Shih <pkshih@realtek.com>
Cc: "jianhao.xu@seu.edu.cn" <jianhao.xu@seu.edu.cn>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] wifi: rtw89: debug: Fix memory leak in __print_txpwr_map()
Date: Fri, 16 Jan 2026 08:23:57 +0000 [thread overview]
Message-ID: <2df4d692f5804c8ca87d3cd26b37081e@realtek.com> (raw)
In-Reply-To: <20260116074836.1199951-1-zilin@seu.edu.cn>
Zilin Guan <zilin@seu.edu.cn> wrote:
>
> In __print_txpwr_map(), memory is allocated to bufp via vzalloc().
> If max_valid_addr is 0, the function returns -EOPNOTSUPP immediately
> without freeing bufp, leading to a memory leak.
>
> Fix this by freeing the temporary buffer bufp in the error path.
>
> Compile tested only. Issue found using a prototype static analysis tool
> and code review.
>
> Fixes: 036042e15770 ("wifi: rtw89: debug: txpwr table supports Wi-Fi 7 chips")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
> drivers/net/wireless/realtek/rtw89/debug.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw89/debug.c
> b/drivers/net/wireless/realtek/rtw89/debug.c
> index 1264c2f82600..c7bd1d0212b6 100644
> --- a/drivers/net/wireless/realtek/rtw89/debug.c
> +++ b/drivers/net/wireless/realtek/rtw89/debug.c
> @@ -834,8 +834,10 @@ static ssize_t __print_txpwr_map(struct rtw89_dev *rtwdev, char
> *buf, size_t buf
> else
> max_valid_addr = map->addr_to;
>
> - if (max_valid_addr == 0)
> + if (max_valid_addr == 0) {
> + vfree(bufp);
> return -EOPNOTSUPP;
> + }
Thank you for catching this.
Since the decision for max_valid_addr doesn't depend on bufp,
how about moving vzalloc down here ?
>
> for (addr = map->addr_from; addr <= max_valid_addr; addr += 4) {
> ret = rtw89_mac_txpwr_read32(rtwdev, RTW89_PHY_0, addr, &val);
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-01-16 8:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 7:48 [PATCH] wifi: rtw89: debug: Fix memory leak in __print_txpwr_map() Zilin Guan
2026-01-16 8:23 ` Zong-Zhe Yang [this message]
2026-01-16 12:11 ` Zilin Guan
2026-01-16 11:04 ` Markus Elfring
2026-01-16 11:41 ` Zong-Zhe Yang
2026-01-16 12:38 ` Markus Elfring
2026-01-16 13:48 ` Johannes Berg
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=2df4d692f5804c8ca87d3cd26b37081e@realtek.com \
--to=kevin_yang@realtek.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
--cc=zilin@seu.edu.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.