From patchwork Tue Jul 16 08:29:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengyi Zhao X-Patchwork-Id: 259376 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B7C712C0191 for ; Tue, 16 Jul 2013 18:30:26 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7BA1E9C0CE; Tue, 16 Jul 2013 04:30:21 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5f9DpGMB1gDw; Tue, 16 Jul 2013 04:30:21 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 05C929C0C5; Tue, 16 Jul 2013 04:30:16 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 535119C0C5 for ; Tue, 16 Jul 2013 04:30:15 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nNSl3fvJMsTm for ; Tue, 16 Jul 2013 04:30:08 -0400 (EDT) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id B02259C0C4 for ; Tue, 16 Jul 2013 04:30:08 -0400 (EDT) Received: by mail-pb0-f44.google.com with SMTP id uo1so444623pbc.31 for ; Tue, 16 Jul 2013 01:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=SJbdvr4QyXutFs4/5FJxZ7pOV/UWPrkvPGWUk7M3oi0=; b=JQYp4WCP8m3o6rE9A8yaXrv8pPvP0UT3RJXE6rHTj9txMOEhfjmlcd4VfkDKdTuBis iLc29sETfnwigF04G/n1IvL+Qb3n8rFmQpYa/mnX5DQhF2dWFAU+Srbt4qUl7rDo1juK P+BMuUqcC3HhnI429sQ4dMhdFCvuMbHkXNowtJG3o0fns8oH5aLaJK/JJzvuhC83m+nP MOqdZJEffuVlOD15O2t43a0lvlKHx+UQysTc24+ksQPM2vCsVqx4qwrJFAig3GU1uDTs IyrMi420yXZxvOOurMi2RSDKEFRjlLvR8929gOjIxFkOVxZyMzUCPNW7IXLqPX2qK9yD qO8Q== X-Received: by 10.68.106.67 with SMTP id gs3mr385095pbb.126.1373963405573; Tue, 16 Jul 2013 01:30:05 -0700 (PDT) Received: from localhost.localdomain ([27.17.36.150]) by mx.google.com with ESMTPSA id nm10sm636379pbc.28.2013.07.16.01.30.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Jul 2013 01:30:04 -0700 (PDT) From: Chengyi Zhao To: hostap@lists.shmoo.com Subject: [PATCH] wpa_supplicant: Cancel delayed scheduled scan when wpa_supplicant cleanups Date: Tue, 16 Jul 2013 16:29:53 +0800 Message-Id: <1373963393-13737-1-git-send-email-chengyix.zhao@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Chengyi Zhao Because delayed scheduled scan will access the member of struct wpa_supplicant which is freed, and result in the crash, the program should cancel delayed scheduled scan when wpa_supplicant cleanups. Signed-hostap: Chengyi Zhao --- wpa_supplicant/scan.c | 16 ++++++++++++++++ wpa_supplicant/scan.h | 1 + wpa_supplicant/wpa_supplicant.c | 1 + 3 files changed, 18 insertions(+) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index bdd6815..b7d9db5 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -1228,6 +1228,22 @@ void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s) wpas_p2p_continue_after_scan(wpa_s); } +/** + * wpa_supplicant_cancel_delayed_sched_scan - Stop a delayed scheduled scans + * @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 diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h index e892479..2144787 100644 --- a/wpa_supplicant/scan.h +++ b/wpa_supplicant/scan.h @@ -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); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 5773013..5984060 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -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);