Commit 9831bcb9 authored by Hante Meuleman's avatar Hante Meuleman Committed by Kalle Valo

brcmfmac: Deleting of p2p device is leaking memory.

When a p2p device gets deleted, the memory for the vif is not being
released. This is solved by reorganizing the cleanup path and
properly freeing the memory.
Reviewed-by: default avatarArend Van Spriel <arend@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarHante Meuleman <meuleman@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 178e9ef9
...@@ -887,6 +887,16 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx) ...@@ -887,6 +887,16 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bssidx)
cancel_work_sync(&ifp->multicast_work); cancel_work_sync(&ifp->multicast_work);
} }
brcmf_net_detach(ifp->ndev); brcmf_net_detach(ifp->ndev);
} else {
/* Only p2p device interfaces which get dynamically created
* end up here. In this case the p2p module should be informed
* about the removal of the interface within the firmware. If
* not then p2p commands towards the firmware will cause some
* serious troublesome side effects. The p2p module will clean
* up the ifp if needed.
*/
brcmf_p2p_ifp_removed(ifp);
kfree(ifp);
} }
} }
...@@ -894,7 +904,8 @@ void brcmf_remove_interface(struct brcmf_if *ifp) ...@@ -894,7 +904,8 @@ void brcmf_remove_interface(struct brcmf_if *ifp)
{ {
if (!ifp || WARN_ON(ifp->drvr->iflist[ifp->bssidx] != ifp)) if (!ifp || WARN_ON(ifp->drvr->iflist[ifp->bssidx] != ifp))
return; return;
brcmf_dbg(TRACE, "Enter, bssidx=%d, ifidx=%d\n", ifp->bssidx,
ifp->ifidx);
brcmf_fws_del_interface(ifp); brcmf_fws_del_interface(ifp);
brcmf_del_if(ifp->drvr, ifp->bssidx); brcmf_del_if(ifp->drvr, ifp->bssidx);
} }
......
...@@ -2130,20 +2130,6 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p, ...@@ -2130,20 +2130,6 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p,
return ERR_PTR(err); return ERR_PTR(err);
} }
/**
* brcmf_p2p_delete_p2pdev() - delete P2P_DEVICE virtual interface.
*
* @vif: virtual interface object to delete.
*/
static void brcmf_p2p_delete_p2pdev(struct brcmf_p2p_info *p2p,
struct brcmf_cfg80211_vif *vif)
{
cfg80211_unregister_wdev(&vif->wdev);
p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL;
brcmf_remove_interface(vif->ifp);
brcmf_free_vif(vif);
}
/** /**
* brcmf_p2p_add_vif() - create a new P2P virtual interface. * brcmf_p2p_add_vif() - create a new P2P virtual interface.
* *
...@@ -2267,9 +2253,11 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) ...@@ -2267,9 +2253,11 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
break; break;
case NL80211_IFTYPE_P2P_DEVICE: case NL80211_IFTYPE_P2P_DEVICE:
if (!p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
return 0;
brcmf_p2p_cancel_remain_on_channel(vif->ifp); brcmf_p2p_cancel_remain_on_channel(vif->ifp);
brcmf_p2p_deinit_discovery(p2p); brcmf_p2p_deinit_discovery(p2p);
brcmf_p2p_delete_p2pdev(p2p, vif); brcmf_remove_interface(vif->ifp);
return 0; return 0;
default: default:
return -ENOTSUPP; return -ENOTSUPP;
...@@ -2301,6 +2289,21 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) ...@@ -2301,6 +2289,21 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
return err; return err;
} }
void brcmf_p2p_ifp_removed(struct brcmf_if *ifp)
{
struct brcmf_cfg80211_info *cfg;
struct brcmf_cfg80211_vif *vif;
brcmf_dbg(INFO, "P2P: device interface removed\n");
vif = ifp->vif;
cfg = wdev_to_cfg(&vif->wdev);
cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL;
rtnl_lock();
cfg80211_unregister_wdev(&vif->wdev);
rtnl_unlock();
brcmf_free_vif(vif);
}
int brcmf_p2p_start_device(struct wiphy *wiphy, struct wireless_dev *wdev) int brcmf_p2p_start_device(struct wiphy *wiphy, struct wireless_dev *wdev)
{ {
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
...@@ -2425,10 +2428,7 @@ void brcmf_p2p_detach(struct brcmf_p2p_info *p2p) ...@@ -2425,10 +2428,7 @@ void brcmf_p2p_detach(struct brcmf_p2p_info *p2p)
if (vif != NULL) { if (vif != NULL) {
brcmf_p2p_cancel_remain_on_channel(vif->ifp); brcmf_p2p_cancel_remain_on_channel(vif->ifp);
brcmf_p2p_deinit_discovery(p2p); brcmf_p2p_deinit_discovery(p2p);
/* remove discovery interface */ brcmf_remove_interface(vif->ifp);
rtnl_lock();
brcmf_p2p_delete_p2pdev(p2p, vif);
rtnl_unlock();
} }
/* just set it all to zero */ /* just set it all to zero */
memset(p2p, 0, sizeof(*p2p)); memset(p2p, 0, sizeof(*p2p));
......
...@@ -157,6 +157,7 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name, ...@@ -157,6 +157,7 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name,
int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev); int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev);
int brcmf_p2p_ifchange(struct brcmf_cfg80211_info *cfg, int brcmf_p2p_ifchange(struct brcmf_cfg80211_info *cfg,
enum brcmf_fil_p2p_if_types if_type); enum brcmf_fil_p2p_if_types if_type);
void brcmf_p2p_ifp_removed(struct brcmf_if *ifp);
int brcmf_p2p_start_device(struct wiphy *wiphy, struct wireless_dev *wdev); int brcmf_p2p_start_device(struct wiphy *wiphy, struct wireless_dev *wdev);
void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev); void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev);
int brcmf_p2p_scan_prep(struct wiphy *wiphy, int brcmf_p2p_scan_prep(struct wiphy *wiphy,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment