brcmfmac: Fix memory leak in brcmf_p2p_create_p2pdev()
diff mbox series

Message ID 20191122191954.17908-1-navid.emamdoost@gmail.com
State Accepted
Commit 5cc509aa83c6acd2c5cd94f99065c39d2bd0a490
Delegated to: Kalle Valo
Headers show
Series
  • brcmfmac: Fix memory leak in brcmf_p2p_create_p2pdev()
Related show

Commit Message

Navid Emamdoost Nov. 22, 2019, 7:19 p.m. UTC
In the implementation of brcmf_p2p_create_p2pdev() the allocated memory
for p2p_vif is leaked when the mac address is the same as primary
interface. To fix this, go to error path to release p2p_vif via
brcmf_free_vif().

Fixes: cb746e47837a ("brcmfmac: check p2pdev mac address uniqueness")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kalle Valo Dec. 18, 2019, 6:21 p.m. UTC | #1
Navid Emamdoost <navid.emamdoost@gmail.com> wrote:

> In the implementation of brcmf_p2p_create_p2pdev() the allocated memory
> for p2p_vif is leaked when the mac address is the same as primary
> interface. To fix this, go to error path to release p2p_vif via
> brcmf_free_vif().
> 
> Fixes: cb746e47837a ("brcmfmac: check p2pdev mac address uniqueness")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Patch applied to wireless-drivers-next.git, thanks.

5cc509aa83c6 brcmfmac: Fix memory leak in brcmf_p2p_create_p2pdev()

Patch
diff mbox series

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
index 7ba9f6a68645..1f5deea5a288 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
@@ -2092,7 +2092,8 @@  static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p,
 	/* firmware requires unique mac address for p2pdev interface */
 	if (addr && ether_addr_equal(addr, pri_ifp->mac_addr)) {
 		bphy_err(drvr, "discovery vif must be different from primary interface\n");
-		return ERR_PTR(-EINVAL);
+		err = -EINVAL;
+		goto fail;
 	}
 
 	brcmf_p2p_generate_bss_mac(p2p, addr);