From patchwork Wed Jun 8 17:07:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maya Erez X-Patchwork-Id: 9165317 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 48F4F60467 for ; Wed, 8 Jun 2016 17:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33F272810E for ; Wed, 8 Jun 2016 17:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2890E282DC; Wed, 8 Jun 2016 17:08:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C17B42810E for ; Wed, 8 Jun 2016 17:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758189AbcFHRH6 (ORCPT ); Wed, 8 Jun 2016 13:07:58 -0400 Received: from wolverine01.qualcomm.com ([199.106.114.254]:48958 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758183AbcFHRH4 (ORCPT ); Wed, 8 Jun 2016 13:07:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qualcomm.com; i=@qualcomm.com; q=dns/txt; s=qcdkim; t=1465405676; x=1496941676; h=from:cc:to:subject:date:message-id:x-mailer:in-reply-to: references; bh=zuf9eKRM7GGzh6fOjLnQP1Ypr0bFIUhcdJUU/xRrjMY=; b=bGvayVKMUC8aYCcMHLbbGRQQcZU8621sUwMLQs+iLCJwKOGm5WrP4L5T z0bcf2nKMoJPeu6hePkcPVK5lkvNYak0XaTvuXKoRcrE1aBZB/DgAXOAt T85gQfj3TrEUUf0i891/8qaiRLz7pBPHKuDXKsYfr8nzPjnATyyn7+VNb 0=; X-IronPort-AV: E=Sophos;i="5.26,440,1459839600"; d="scan'208";a="199197147" Received: from ironmsg03-l-new.qualcomm.com (HELO Ironmsg03-L.qualcomm.com) ([10.53.140.110]) by wolverine01.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Jun 2016 10:07:56 -0700 From: Maya Erez Cc: Lior David , linux-wireless@vger.kernel.org, wil6210@qualcomm.com, Maya Erez X-IronPort-AV: E=McAfee;i="5700,7163,8190"; a="1162664196" Received: from lx-merez.mea.qualcomm.com ([10.18.173.103]) by Ironmsg03-L.qualcomm.com with ESMTP; 08 Jun 2016 10:07:54 -0700 To: Kalle Valo Subject: [PATCH 2/2] wil6210: abort P2P search when stopping P2P device Date: Wed, 8 Jun 2016 20:07:48 +0300 Message-Id: <1465405668-15881-3-git-send-email-qca_merez@qca.qualcomm.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1465405668-15881-1-git-send-email-qca_merez@qca.qualcomm.com> References: <1465405668-15881-1-git-send-email-qca_merez@qca.qualcomm.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lior David The nl80211 layer expects P2P search operation to be aborted if needed when stopping P2P device. If the P2P search operation is still running after returning from stop_p2p_device it causes a WARN_ON and possibly a kernel crash. Fix this by aborting the P2P search in wil_cfg80211_stop_p2p_device and preventing P2P search from being started on a stopped P2P device. Note, the fix does not cover the case where a regular scan is started on the P2P device. It will be completed in the future when support is added for aborting a scan operation. Signed-off-by: Lior David Signed-off-by: Maya Erez --- drivers/net/wireless/ath/wil6210/cfg80211.c | 16 ++++++++++++++++ drivers/net/wireless/ath/wil6210/wil6210.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c index 5769811..62bf933 100644 --- a/drivers/net/wireless/ath/wil6210/cfg80211.c +++ b/drivers/net/wireless/ath/wil6210/cfg80211.c @@ -378,6 +378,10 @@ static int wil_cfg80211_scan(struct wiphy *wiphy, /* social scan on P2P_DEVICE is handled as p2p search */ if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE && wil_p2p_is_social_scan(request)) { + if (!wil->p2p.p2p_dev_started) { + wil_err(wil, "P2P search requested on stopped P2P device\n"); + return -EIO; + } wil->scan_request = request; wil->radio_wdev = wdev; rc = wil_p2p_search(wil, request); @@ -1351,6 +1355,7 @@ static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy, struct wil6210_priv *wil = wiphy_to_wil(wiphy); wil_dbg_misc(wil, "%s: entered\n", __func__); + wil->p2p.p2p_dev_started = 1; return 0; } @@ -1358,8 +1363,19 @@ static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev) { struct wil6210_priv *wil = wiphy_to_wil(wiphy); + u8 started; wil_dbg_misc(wil, "%s: entered\n", __func__); + mutex_lock(&wil->mutex); + started = wil_p2p_stop_discovery(wil); + if (started && wil->scan_request) { + cfg80211_scan_done(wil->scan_request, 1); + wil->scan_request = NULL; + wil->radio_wdev = wil->wdev; + } + mutex_unlock(&wil->mutex); + + wil->p2p.p2p_dev_started = 0; } static struct cfg80211_ops wil_cfg80211_ops = { diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h index 1feaf5a..ecab4af 100644 --- a/drivers/net/wireless/ath/wil6210/wil6210.h +++ b/drivers/net/wireless/ath/wil6210/wil6210.h @@ -458,6 +458,7 @@ struct wil_tid_crypto_rx { struct wil_p2p_info { struct ieee80211_channel listen_chan; u8 discovery_started; + u8 p2p_dev_started; u64 cookie; struct timer_list discovery_timer; /* listen/search duration */ struct work_struct discovery_expired_work; /* listen/search expire */