Attempt to catch scan cancellations at exactly the wrong time from occuring.

The scan code unlocks the comlock and calls into the driver.  It then
assumes the state hasn't changed from underneath it.

Although I haven't seen this particular condition trigger, I'd like to
be informed if I or anyone else sees it.

What I'm thinking may occur:

* A cancellation comes in during the scan_end call;
* the cancel flag is set;
* but it's never checked, so scandone isn't updated;
* .. and the interface stays in the STA power save mode.

It's a subtle race, if it even exists.

PR:		kern/163318
This commit is contained in:
Adrian Chadd 2012-03-02 02:53:43 +00:00
parent c3173381be
commit 66b74386c7

View File

@ -959,6 +959,19 @@ scan_task(void *arg, int pending)
ic->ic_scan_end(ic); /* notify driver */
IEEE80211_LOCK(ic);
/*
* Since a cancellation may have occured during one of the
* driver calls (whilst unlocked), update scandone.
*/
if (scandone == 0 &&
((SCAN_PRIVATE(ss)->ss_iflags & ISCAN_CANCEL) != 0)) {
/* XXX printf? */
if_printf(vap->iv_ifp,
"%s: OOPS! scan cancelled during driver call!\n",
__func__);
}
scandone |= ((SCAN_PRIVATE(ss)->ss_iflags & ISCAN_CANCEL) != 0);
/*
* Record scan complete time. Note that we also do
* this when canceled so any background scan will