Cancel delayed scheduled scan when wpa_supplicant cleans up

Because a delayed scheduled scan will access the members of struct
wpa_supplicant which is freed and this can result in a crash,
wpa_supplicant needs to cancel delayed scheduled scan during cleanups.

Signed-hostap: Chengyi Zhao <chengyix.zhao@gmail.com>
This commit is contained in:
Chengyi Zhao 2013-07-20 17:47:02 +03:00 committed by Jouni Malinen
parent 69dd2967db
commit 831770bffe
3 changed files with 19 additions and 0 deletions

View file

@ -1229,6 +1229,23 @@ void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s)
}
/**
* wpa_supplicant_cancel_delayed_sched_scan - Stop a delayed scheduled scan
* @wpa_s: Pointer to wpa_supplicant data
*
* This function is used to stop a delayed scheduled scan.
*/
void wpa_supplicant_cancel_delayed_sched_scan(struct wpa_supplicant *wpa_s)
{
if (!wpa_s->sched_scan_supported)
return;
wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling delayed sched scan");
eloop_cancel_timeout(wpa_supplicant_delayed_sched_scan_timeout,
wpa_s, NULL);
}
/**
* wpa_supplicant_cancel_sched_scan - Stop running scheduled scans
* @wpa_s: Pointer to wpa_supplicant data

View file

@ -15,6 +15,7 @@ int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant *wpa_s,
int sec, int usec);
int wpa_supplicant_req_sched_scan(struct wpa_supplicant *wpa_s);
void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
void wpa_supplicant_cancel_delayed_sched_scan(struct wpa_supplicant *wpa_s);
void wpa_supplicant_cancel_sched_scan(struct wpa_supplicant *wpa_s);
void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
int scanning);

View file

@ -421,6 +421,7 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
wpa_bss_deinit(wpa_s);
wpa_supplicant_cancel_delayed_sched_scan(wpa_s);
wpa_supplicant_cancel_scan(wpa_s);
wpa_supplicant_cancel_auth_timeout(wpa_s);
eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, wpa_s, NULL);