Skip to content

Commit

Permalink
brcmsmac: fix memory leak in wlc_phy_attach_lcnphy
Browse files Browse the repository at this point in the history
[ Upstream commit f444329 ]

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@sslab.ics.keio.ac.jp>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200908121743.23108-1-keitasuzuki.park@sslab.ics.keio.ac.jp
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
quasi-mod authored and gregkh committed Oct 29, 2020
1 parent 061d2f3 commit d5eb55b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
kfree(pi->u.pi_lcnphy);
return false;
}

if (LCNREV_IS(pi->pubpi.phy_rev, 1)) {
if (pi_lcn->lcnphy_tempsense_option == 3) {
Expand Down

0 comments on commit d5eb55b

Please sign in to comment.