Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2218649pxp; Mon, 21 Mar 2022 14:09:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9ZvqcQthLOk9R8eoQmi42Mvd57mim0sCdOIAFxHw+ggd2nlvAMqPwdyfGDuRO9Tbxqf+O X-Received: by 2002:a17:902:8f82:b0:151:5d30:a019 with SMTP id z2-20020a1709028f8200b001515d30a019mr14536937plo.145.1647896975533; Mon, 21 Mar 2022 14:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647896975; cv=none; d=google.com; s=arc-20160816; b=APEM8vCIhho45UijYykunjdtBLOHpzyDrr2Kph7ayKzpWPhOhzGOx0wVjcUedTKDfe 2qJmQ0QvHomfOU8e9LRu1507yqBhOJeoD621OyVcrg8I9/KwK+O6GB5GAJibNA4jAjEJ znVlqkj2CSv95TfBjxALMua5AcPZZN1Y06DTbZUic0H9jXuZ67TqTDyAX7gTWT1b8yKj nVc5Kq7KbQoKUKwWRQpIXJX/HLMwyO9yJVVc5SKGn/ZnUfZbHplpywpX4Unhir8QNrS1 XgJCIAo+6W7Pwc9WmOVQomGsLEy4R94Hbba2MzdKmzKMWGj3ouVZdAB73FMHpINDIdJ/ xlVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XCqBpccjcNXkw8O9oNUVFQJT/haogygOhyRJMS2AB2E=; b=rsJWY+ur8SeW3epyzyhf7y3hz9NEFq/Apd5l4YLoWrPid+FHQ+ripjankYM1oEFWdf twjnIG3C7CE74YJlrUDHxgtYcsPFafdnc5iBdBuaYW6NzBxeJjASDFFR2vFWVY0/pBlo xITY4XWnKBdShZ3KBcAdtnRxMXf3HZ9ej8r8idvGfq4/70qi8GPx3PbFi0/c/VdoLd5V NQzkkmr0zpTgpcgCmPhlW6O35Fzf6vHBiHsgx5lK2O8kTi1q1JaYdiKzH3XTjzbzi+Un /dZ+g6YJ7F17wl9rHX61xinGcBUI+/JbLKrrtTE8QhDBqeD3s8ImAGiTNH4UNN6Wvrm+ i59g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="N3CWSeh/"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o3-20020a17090ad20300b001c69d26755esi299115pju.134.2022.03.21.14.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 14:09:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="N3CWSeh/"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76D4C1C5932; Mon, 21 Mar 2022 14:02:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244304AbiCSWtj (ORCPT + 70 others); Sat, 19 Mar 2022 18:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236144AbiCSWth (ORCPT ); Sat, 19 Mar 2022 18:49:37 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 797603D1F2 for ; Sat, 19 Mar 2022 15:48:14 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id d10so23283900eje.10 for ; Sat, 19 Mar 2022 15:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XCqBpccjcNXkw8O9oNUVFQJT/haogygOhyRJMS2AB2E=; b=N3CWSeh/NWG8EuFwVWQYxoMS4aRFPjr2bFPKL175b+2knlUAgeeNcl/yP9PpbSdHEK +7RuT16xi3r0qkiqCNKw5XGFRermvxjJkwy/MqbqJnuuObPrhp4gcwwGdiiIe96DP4BK BHD51lK0B1vN6gdnkyUmn+VOuCJuEkc1W+f9SAVwS7YWL1bqBOQql+ZT/ktp5wKdqATK +rf3kfFke6413I9nDwYfJbP/u+DFt+vp29DZeUsqnTt4wFBoXRUDnzLoBlykRpm9I8Yl M0Bw6HFrnDAIBziDz6IfXhyN6ZsT+r5xvpm0YWXQ7mBhagvr2yaiPUMfqjN78Bdzd869 lJpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XCqBpccjcNXkw8O9oNUVFQJT/haogygOhyRJMS2AB2E=; b=1nfqEJaxH4g96eghq69I1xN7dbqdCioNXwVPbQUbeENZK4UUUi1t5DBNz+kuvqiXcq LvG6BUq9iobPGXDG8TKOk058ykjqIwuI3TZV41cwoxixTuOOAkekxD8MiWhKjQgGcHmp 19PWz5iu9BlcRKnFohFYzRYCMw7HtfCGvxR7LPVPur6sNwOkf8UKDAHJ5k+QYRytRpwH gifTyz8za9uOvBxs0Qt/Cb2ItnUi7oihEBVo8LFnrI/XuzVER2hubmGyGE1Aq8pEpVlF mdC7XlBBmkdQSXyADNI9vMX7oBU6/GlaEZ9o8YCb5cB06PQ1MnXff5R3p8QwIDF3Kb3C hxXw== X-Gm-Message-State: AOAM531xipGh3Vj3L9/xkxOX+FBBp4vXyfmdeZZ8BTWGP4V8wMDYdClP pglBkTOCh3QEH8WP9349Gxi+dpnPIiI= X-Received: by 2002:a17:906:58c7:b0:6da:955b:d300 with SMTP id e7-20020a17090658c700b006da955bd300mr14544930ejs.481.1647730093110; Sat, 19 Mar 2022 15:48:13 -0700 (PDT) Received: from nlaptop.localdomain (178-117-137-225.access.telenet.be. [178.117.137.225]) by smtp.gmail.com with ESMTPSA id b2-20020a17090630c200b006d58f94acecsm5301292ejb.210.2022.03.19.15.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Mar 2022 15:48:12 -0700 (PDT) From: Niels Dossche To: linux-wireless@vger.kernel.org Cc: Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , Xinming Hu , Kalle Valo , Niels Dossche Subject: [PATCH RFT] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue Date: Sat, 19 Mar 2022 23:47:52 +0100 Message-Id: <20220319224751.72241-1-dossche.niels@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org cfg80211_ch_switch_notify uses ASSERT_WDEV_LOCK to assert that net_device->ieee80211_ptr->mtx is held during the function's execution. mwifiex_dfs_chan_sw_work_queue is one of its callers, which does not hold that lock, therefore violating the assertion. Add a lock around the call. Disclaimer: I am currently working on a static analyser to detect missing locks. This was a reported case. I manually verified the report by looking at the code, so that I do not send wrong information or patches. After concluding that this seems to be a true positive, I created this patch. However, as I do not in fact have this particular hardware, I was unable to test it. Signed-off-by: Niels Dossche --- drivers/net/wireless/marvell/mwifiex/11h.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/11h.c b/drivers/net/wireless/marvell/mwifiex/11h.c index d2ee6469e67b..f2cba764024e 100644 --- a/drivers/net/wireless/marvell/mwifiex/11h.c +++ b/drivers/net/wireless/marvell/mwifiex/11h.c @@ -285,6 +285,7 @@ void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work) struct mwifiex_private *priv = container_of(delayed_work, struct mwifiex_private, dfs_chan_sw_work); + struct net_device *netdev; bss_cfg = &priv->bss_cfg; if (!bss_cfg->beacon_period) { @@ -301,7 +302,11 @@ void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work) return; } + netdev = priv->netdev; + mwifiex_dbg(priv->adapter, MSG, "indicating channel switch completion to kernel\n"); - cfg80211_ch_switch_notify(priv->netdev, &priv->dfs_chandef); + mutex_lock(&netdev->ieee80211_ptr->mtx); + cfg80211_ch_switch_notify(netdev, &priv->dfs_chandef); + mutex_unlock(&netdev->ieee80211_ptr->mtx); } -- 2.35.1