Skip to content

Commit 69fecf5

Browse files
Lior Davidkvalo
authored andcommitted
wil6210: ensure P2P device is stopped before removing interface
User space can remove the P2P management interface while it is active (for example, while listen/search is active) and this can cause a crash. Ensure the P2P device is fully stopped before removing. Signed-off-by: Lior David <[email protected]> Signed-off-by: Maya Erez <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent d83ad4c commit 69fecf5

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

drivers/net/wireless/ath/wil6210/cfg80211.c

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,34 @@ static int wil_cfg80211_dump_station(struct wiphy *wiphy,
382382
return rc;
383383
}
384384

385+
static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
386+
struct wireless_dev *wdev)
387+
{
388+
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
389+
390+
wil_dbg_misc(wil, "start_p2p_device: entered\n");
391+
wil->p2p.p2p_dev_started = 1;
392+
return 0;
393+
}
394+
395+
static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
396+
struct wireless_dev *wdev)
397+
{
398+
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
399+
struct wil_p2p_info *p2p = &wil->p2p;
400+
401+
if (!p2p->p2p_dev_started)
402+
return;
403+
404+
wil_dbg_misc(wil, "stop_p2p_device: entered\n");
405+
mutex_lock(&wil->mutex);
406+
mutex_lock(&wil->p2p_wdev_mutex);
407+
wil_p2p_stop_radio_operations(wil);
408+
p2p->p2p_dev_started = 0;
409+
mutex_unlock(&wil->p2p_wdev_mutex);
410+
mutex_unlock(&wil->mutex);
411+
}
412+
385413
static struct wireless_dev *
386414
wil_cfg80211_add_iface(struct wiphy *wiphy, const char *name,
387415
unsigned char name_assign_type,
@@ -430,6 +458,7 @@ static int wil_cfg80211_del_iface(struct wiphy *wiphy,
430458
return -EINVAL;
431459
}
432460

461+
wil_cfg80211_stop_p2p_device(wiphy, wdev);
433462
wil_p2p_wdev_free(wil);
434463

435464
return 0;
@@ -1661,34 +1690,6 @@ static int wil_cfg80211_change_bss(struct wiphy *wiphy,
16611690
return 0;
16621691
}
16631692

1664-
static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
1665-
struct wireless_dev *wdev)
1666-
{
1667-
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1668-
1669-
wil_dbg_misc(wil, "start_p2p_device: entered\n");
1670-
wil->p2p.p2p_dev_started = 1;
1671-
return 0;
1672-
}
1673-
1674-
static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
1675-
struct wireless_dev *wdev)
1676-
{
1677-
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1678-
struct wil_p2p_info *p2p = &wil->p2p;
1679-
1680-
if (!p2p->p2p_dev_started)
1681-
return;
1682-
1683-
wil_dbg_misc(wil, "stop_p2p_device: entered\n");
1684-
mutex_lock(&wil->mutex);
1685-
mutex_lock(&wil->p2p_wdev_mutex);
1686-
wil_p2p_stop_radio_operations(wil);
1687-
p2p->p2p_dev_started = 0;
1688-
mutex_unlock(&wil->p2p_wdev_mutex);
1689-
mutex_unlock(&wil->mutex);
1690-
}
1691-
16921693
static int wil_cfg80211_set_power_mgmt(struct wiphy *wiphy,
16931694
struct net_device *dev,
16941695
bool enabled, int timeout)

0 commit comments

Comments
 (0)