Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9db9725e authored by Lior David's avatar Lior David Committed by Gerrit - the friendly Code Review server
Browse files

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.

Change-Id: Ibc94f12bc63f2ba31ede24afffd9c5acbf95467a
Signed-off-by: default avatarLior David <qca_liord@qca.qualcomm.com>
Signed-off-by: default avatarMaya Erez <qca_merez@qca.qualcomm.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
Git-commit: 69fecf599f48e258984b2ffdf0a4c65a35a31287
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git


Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
parent 821b100a
Loading
Loading
Loading
Loading
+29 −28
Original line number Diff line number Diff line
@@ -455,6 +455,34 @@ static int wil_cfg80211_dump_station(struct wiphy *wiphy,
	return rc;
}

static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
					 struct wireless_dev *wdev)
{
	struct wil6210_priv *wil = wiphy_to_wil(wiphy);

	wil_dbg_misc(wil, "start_p2p_device: entered\n");
	wil->p2p.p2p_dev_started = 1;
	return 0;
}

static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
					 struct wireless_dev *wdev)
{
	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
	struct wil_p2p_info *p2p = &wil->p2p;

	if (!p2p->p2p_dev_started)
		return;

	wil_dbg_misc(wil, "stop_p2p_device: entered\n");
	mutex_lock(&wil->mutex);
	mutex_lock(&wil->p2p_wdev_mutex);
	wil_p2p_stop_radio_operations(wil);
	p2p->p2p_dev_started = 0;
	mutex_unlock(&wil->p2p_wdev_mutex);
	mutex_unlock(&wil->mutex);
}

static struct wireless_dev *
wil_cfg80211_add_iface(struct wiphy *wiphy, const char *name,
		       unsigned char name_assign_type,
@@ -503,6 +531,7 @@ static int wil_cfg80211_del_iface(struct wiphy *wiphy,
		return -EINVAL;
	}

	wil_cfg80211_stop_p2p_device(wiphy, wdev);
	wil_p2p_wdev_free(wil);

	return 0;
@@ -1737,34 +1766,6 @@ static int wil_cfg80211_change_bss(struct wiphy *wiphy,
	return 0;
}

static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
					 struct wireless_dev *wdev)
{
	struct wil6210_priv *wil = wiphy_to_wil(wiphy);

	wil_dbg_misc(wil, "start_p2p_device: entered\n");
	wil->p2p.p2p_dev_started = 1;
	return 0;
}

static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
					 struct wireless_dev *wdev)
{
	struct wil6210_priv *wil = wiphy_to_wil(wiphy);
	struct wil_p2p_info *p2p = &wil->p2p;

	if (!p2p->p2p_dev_started)
		return;

	wil_dbg_misc(wil, "stop_p2p_device: entered\n");
	mutex_lock(&wil->mutex);
	mutex_lock(&wil->p2p_wdev_mutex);
	wil_p2p_stop_radio_operations(wil);
	p2p->p2p_dev_started = 0;
	mutex_unlock(&wil->p2p_wdev_mutex);
	mutex_unlock(&wil->mutex);
}

static int wil_cfg80211_set_power_mgmt(struct wiphy *wiphy,
				       struct net_device *dev,
				       bool enabled, int timeout)