diff mbox

wpa_supplicant: don't try to stop sched scan when initialization fails

Message ID 1383485279-3055-1-git-send-email-ilan.peer@intel.com
State Changes Requested
Headers show

Commit Message

Peer, Ilan Nov. 3, 2013, 1:27 p.m. UTC
From: Luciano Coelho <luciano.coelho@intel.com>

If something goes wrong during initialization, we were trying to stop
schedule scan (and thus read data from wpa_s->drv_priv), but the
driver data doesn't exist, so we were segfaulting.  Fix this by not
trying to stop sched scans if the private driver data doesn't exist.

Signed-hostap: Luciano Coelho <luciano.coelho@intel.com>

---
 wpa_supplicant/wpa_supplicant.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jouni Malinen Nov. 5, 2013, 8:45 a.m. UTC | #1
On Sun, Nov 03, 2013 at 03:27:59PM +0200, Ilan Peer wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
> 
> If something goes wrong during initialization, we were trying to stop
> schedule scan (and thus read data from wpa_s->drv_priv), but the
> driver data doesn't exist, so we were segfaulting.  Fix this by not
> trying to stop sched scans if the private driver data doesn't exist.

Wasn't this issue introduced by the earlier commit in this set
("wpa_supplicant: fix 2 bugs in cancel sched scan")? Before that,
wpa_supplicant_cancel_sched_scan() exited immediately on
!wpa_s->scan_scanning and I'd assume that could not be set without the
driver having been initialized.. In other words, this commit should
really be merged to the other one. That said, it would probably make
sense to merge all these three sched_scan commits (i.e., also
"wpa_supplicant: cancel sched scan on all interfaces") since they seem
to be very much related and addressing issues from the previous commit.
Peer, Ilan Nov. 5, 2013, 11:26 a.m. UTC | #2
> -----Original Message-----
> From: Coelho, Luciano
> Sent: Tuesday, November 05, 2013 10:55
> To: Jouni Malinen
> Cc: Peer, Ilan; hostap@lists.shmoo.com; Spinadel, David
> Subject: Re: [PATCH] wpa_supplicant: don't try to stop sched scan when
> initialization fails
> 
> On Tue, 2013-11-05 at 10:45 +0200, Jouni Malinen wrote:
> > On Sun, Nov 03, 2013 at 03:27:59PM +0200, Ilan Peer wrote:
> > > From: Luciano Coelho <luciano.coelho@intel.com>
> > >
> > > If something goes wrong during initialization, we were trying to
> > > stop schedule scan (and thus read data from wpa_s->drv_priv), but
> > > the driver data doesn't exist, so we were segfaulting.  Fix this by
> > > not trying to stop sched scans if the private driver data doesn't exist.
> >
> > Wasn't this issue introduced by the earlier commit in this set
> > ("wpa_supplicant: fix 2 bugs in cancel sched scan")? Before that,
> > wpa_supplicant_cancel_sched_scan() exited immediately on
> > !wpa_s->scan_scanning and I'd assume that could not be set without the
> > driver having been initialized.. In other words, this commit should
> > really be merged to the other one.
> 
> I agree.  I wrote this patch on top of our internal tree, which already included
> the commit that broke this.  My patch should be squashed.
> 
> --
> Luca.

Sorry for this. I'll squash based on the decision on the other patch.

Regards,

Ilan
diff mbox

Patch

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 3301b14..f776d49 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -454,7 +454,9 @@  static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
 	offchannel_deinit(wpa_s);
 #endif /* CONFIG_OFFCHANNEL */
 
-	wpa_supplicant_cancel_sched_scan(wpa_s);
+	/* no need to stop sched scans if the driver failed to initialize */
+	if (wpa_s->drv_priv)
+		wpa_supplicant_cancel_sched_scan(wpa_s);
 
 	os_free(wpa_s->next_scan_freqs);
 	wpa_s->next_scan_freqs = NULL;