RE: [PATCH] wifi: rtw89: debug: Fix memory leak in __print_txpwr_map()
From: Zilin Guan
Date: Fri Jan 16 2026 - 07:11:50 EST
On Fri, Jan 16, 2026 at 08:23:57AM +0000, Zong-Zhe Yang wrote:
> > @@ -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
> >
Thanks for your suggestion. I agree that moving vzalloc() after the check
is a cleaner solution. I will send a v2 patch to address this.
Best Regards,
Zilin Guan