From patchwork Fri Jan 25 11:48:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 10781261 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 961C117F0 for ; Fri, 25 Jan 2019 11:48:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 845A62F147 for ; Fri, 25 Jan 2019 11:48:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78F0A2F201; Fri, 25 Jan 2019 11:48:34 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 213C62F1FE for ; Fri, 25 Jan 2019 11:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728007AbfAYLsd (ORCPT ); Fri, 25 Jan 2019 06:48:33 -0500 Received: from s3.sipsolutions.net ([144.76.43.62]:55806 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726256AbfAYLsc (ORCPT ); Fri, 25 Jan 2019 06:48:32 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92-RC4) (envelope-from ) id 1gmzyI-0007S0-Mm; Fri, 25 Jan 2019 12:48:30 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Sara Sharon Subject: [PATCH 06/12] cfg80211: properly free nontransmitted list on all paths Date: Fri, 25 Jan 2019 12:48:19 +0100 Message-Id: <20190125114825.5872-6-johannes@sipsolutions.net> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190125114825.5872-1-johannes@sipsolutions.net> References: <20190125114825.5872-1-johannes@sipsolutions.net> 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: Sara Sharon Free the list inside __cfg80211_unlink_bss and not in cfg80211_unlink_bss, since not all paths call the later. Signed-off-by: Sara Sharon Signed-off-by: Johannes Berg --- net/wireless/scan.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 1e95b46e84e2..1f5535ec4b01 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -152,6 +152,9 @@ static inline void bss_ref_put(struct cfg80211_registered_device *rdev, static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *rdev, struct cfg80211_internal_bss *bss) { + struct cfg80211_bss *nontrans_bss, *tmp; + struct cfg80211_internal_bss *tmp1; + lockdep_assert_held(&rdev->bss_lock); if (!list_empty(&bss->hidden_list)) { @@ -168,8 +171,26 @@ static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *rdev, list_del_init(&bss->hidden_list); } - list_del_init(&bss->list); + /* + * If the deleted entry is a non-transmitting BSS, just remove it + * from the list. + * if it is the transmitting BSS - free the entire list. + */ + if (!bss->pub.transmitted_bss && + !list_empty(&bss->pub.nontrans_list)) { + list_for_each_entry_safe(nontrans_bss, tmp, + &bss->pub.nontrans_list, + nontrans_list) { + tmp1 = container_of(nontrans_bss, + struct cfg80211_internal_bss, pub); + if (__cfg80211_unlink_bss(rdev, tmp1)) + rdev->bss_generation++; + } + } list_del_init(&bss->pub.nontrans_list); + + list_del_init(&bss->list); + rb_erase(&bss->rbn, &rdev->bss_tree); rdev->bss_entries--; WARN_ONCE((rdev->bss_entries == 0) ^ list_empty(&rdev->bss_list), @@ -1787,8 +1808,7 @@ EXPORT_SYMBOL(cfg80211_put_bss); void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub) { struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); - struct cfg80211_internal_bss *bss, *tmp1; - struct cfg80211_bss *nontrans_bss, *tmp; + struct cfg80211_internal_bss *bss; if (WARN_ON(!pub)) return; @@ -1796,21 +1816,11 @@ void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub) bss = container_of(pub, struct cfg80211_internal_bss, pub); spin_lock_bh(&rdev->bss_lock); - if (list_empty(&bss->list)) - goto out; - list_for_each_entry_safe(nontrans_bss, tmp, - &pub->nontrans_list, - nontrans_list) { - tmp1 = container_of(nontrans_bss, - struct cfg80211_internal_bss, pub); - if (__cfg80211_unlink_bss(rdev, tmp1)) + if (!list_empty(&bss->list)) + if (__cfg80211_unlink_bss(rdev, bss)) rdev->bss_generation++; - } - if (__cfg80211_unlink_bss(rdev, bss)) - rdev->bss_generation++; -out: spin_unlock_bh(&rdev->bss_lock); } EXPORT_SYMBOL(cfg80211_unlink_bss);