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

Commit 1cdd59ce authored by Johannes Berg's avatar Johannes Berg
Browse files

cfg80211: simplify and correct P2P-Device scan check



If the driver for some reason successfully finishes
scanning while in p2p_stop_device(), cfg80211 will
still set it to aborted. Simplify this code using the
new 'notified' value and only mark it aborted in case
the driver didn't notify cfg80211 at all (in which
case we also leak the request to not crash, this is
a driver bug.)

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 8d61ffa5
Loading
Loading
Loading
Loading
+7 −10
Original line number Original line Diff line number Diff line
@@ -204,18 +204,15 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
	rdev->opencount--;
	rdev->opencount--;


	if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
	if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
		bool busy = work_busy(&rdev->scan_done_wk);

		/*
		/*
		 * If the work isn't pending or running (in which case it would
		 * If the scan request wasn't notified as done, set it
		 * be waiting for the lock we hold) the driver didn't properly
		 * to aborted and leak it after a warning. The driver
		 * cancel the scan when the interface was removed. In this case
		 * should have notified us that it ended at the latest
		 * warn and leak the scan request object to not crash later.
		 * during rdev_stop_p2p_device().
		 */
		 */
		WARN_ON(!busy);
		if (WARN_ON(!rdev->scan_req->notified))

			rdev->scan_req->aborted = true;
			rdev->scan_req->aborted = true;
		___cfg80211_scan_done(rdev, !busy);
		___cfg80211_scan_done(rdev, !rdev->scan_req->notified);
	}
	}
}
}