[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bad4e33a-af2f-b44f-63e5-56386c312a91@broadcom.com>
Date: Mon, 7 Sep 2020 22:46:52 +0200
From: Arend Van Spriel <arend.vanspriel@...adcom.com>
To: Keita Suzuki <keitasuzuki.park@...ab.ics.keio.ac.jp>
Cc: takafumi@...ab.ics.keio.ac.jp,
Franky Lin <franky.lin@...adcom.com>,
Hante Meuleman <hante.meuleman@...adcom.com>,
Chi-Hsien Lin <chi-hsien.lin@...ress.com>,
Wright Feng <wright.feng@...ress.com>,
Kalle Valo <kvalo@...eaurora.org>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
"open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER"
<linux-wireless@...r.kernel.org>,
"open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER"
<brcm80211-dev-list.pdl@...adcom.com>,
"open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER"
<brcm80211-dev-list@...ress.com>,
"open list:NETWORKING DRIVERS" <netdev@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] brcmsmac: fix potential memory leak in
wlc_phy_attach_lcnphy
On 9/7/2020 6:22 PM, Keita Suzuki wrote:
> When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy,
> the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be
> freed in the caller function.
>
> Fix this by calling wlc_phy_detach_lcnphy in the error handler of
> wlc_phy_txpwr_srom_read_lcnphy before returning.
>
> Signed-off-by: Keita Suzuki <keitasuzuki.park@...ab.ics.keio.ac.jp>
> ---
> .../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> index 7ef36234a25d..6d70f51b2ddf 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> @@ -5065,8 +5065,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
> pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft;
> pi->pi_fptr.detach = wlc_phy_detach_lcnphy;
>
> - if (!wlc_phy_txpwr_srom_read_lcnphy(pi))
> + if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) {
> + wlc_phy_detach_lcnphy(pi);
Essentially the same but I prefer to simply do the kfree() call directly
here as we also allocate in this function.
Thanks,
Arend
Powered by blists - more mailing lists