Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1862152rwb; Fri, 19 Aug 2022 10:37:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lCjkHxH65iwWkr19258XpZHBSMPAvTZpUJRReCbAwgMnZsyfh25ki2QcSg+x9hZ0Yo2Og X-Received: by 2002:a17:90b:3e82:b0:1f7:3792:d33c with SMTP id rj2-20020a17090b3e8200b001f73792d33cmr9326595pjb.222.1660930620149; Fri, 19 Aug 2022 10:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930620; cv=none; d=google.com; s=arc-20160816; b=LgoCDbVEK+PA5GJNlyYKB0wU/p4Y+Ke24KEinCbKABSVpGdUdwfJM0UB/TRSaaglb8 SuRKfYGgFbdiVFHWE6GFKzhMlAzqZbQnIhjxyEauaSQSZUL/pSJOXWyVBHIf27PvcdOD QmQvT+fdf+B6zvpt45b7pGr32ouu3RE3OHiJPv2v6FgxKEyWjn4q9Sty0HoN/rfUAJNQ KFZomKXCNHKeCgjDuvzteToH2UKIPLtuqNoELCc7jWU4IuOw/Cchxak3Bagz9Fz9H3kL bxQVFYAtOefnajAP9GM1SGKh4+WGObZxTG5z8yt8MHNcaZQeFMj/wr0tWlBRIuE/Ybr0 m8rw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FFdJZSY2irf7204s5VkE9rQYhJJtbrNyWOxzXCP+Ong=; b=u/iSy07Mb+sQ4Msgb3T87MyTzORu9tekwl5M1glXOLPwewY/3gAcVWvmLf5p0zEK6p rtrwiPspKRm0e3AzNWzxWxSJ4MOM+JzT/1DKRDwmv91kN1+l35QgMby2EgraUD1/W88Q QCckMSEVIPDwzP/ymHUSpkmW91HU3CHXpa9AQb2bzofJ1zuEU4NHym37ohxpTTpKviq8 KCyM1f7XnBXkKaPKj9zo9h1vW2m23piJKXuUVHMeS3nhLg1ZRP8pFoU8evuRk/Lcv5uW ngr0z4yOS/gDXXTzahDs8yaquhRtELLs6IihpLwvwUW0UUhja+xC6SpukZx0Lm5pWZgV sIJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XyOpaVLp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a056a0022d100b0052acaf4a3c0si4819757pfj.17.2022.08.19.10.36.49; Fri, 19 Aug 2022 10:37:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XyOpaVLp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351378AbiHSQFh (ORCPT + 99 others); Fri, 19 Aug 2022 12:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351517AbiHSQBy (ORCPT ); Fri, 19 Aug 2022 12:01:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E044810A77F; Fri, 19 Aug 2022 08:53:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B1376616FD; Fri, 19 Aug 2022 15:53:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80746C433C1; Fri, 19 Aug 2022 15:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924411; bh=BvP7g51laNauU/B54MCvWwaZU0wJOLBo96NNZR4aWbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XyOpaVLpfeGUjaA/suJEjaifWsLLT8FlR2ndVOss3KUZaClsf4fXwE8/Vo5TrQUZ1 Gt0WZcsxAp2ULanJWqLSP/Dw8viIFh/tHkEm5sLZRNNK+YH8Ns+tDNgoWE14fEsfnI 1SKST+zDDnTzoM3iiOZSFh/Lkptoncyrg+oy1VFk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 162/545] ath11k: fix netdev open race Date: Fri, 19 Aug 2022 17:38:52 +0200 Message-Id: <20220819153836.607181862@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-kernel@vger.kernel.org From: Johan Hovold [ Upstream commit d4ba1ff87b17e81686ada8f429300876f55f95ad ] Make sure to allocate resources needed before registering the device. This specifically avoids having a racing open() trigger a BUG_ON() in mod_timer() when ath11k_mac_op_start() is called before the mon_reap_timer as been set up. I did not see this issue with next-20220310, but I hit it on every probe with next-20220511. Perhaps some timing changed in between. Here's the backtrace: [ 51.346947] kernel BUG at kernel/time/timer.c:990! [ 51.346958] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ... [ 51.578225] Call trace: [ 51.583293] __mod_timer+0x298/0x390 [ 51.589518] mod_timer+0x14/0x20 [ 51.595368] ath11k_mac_op_start+0x41c/0x4a0 [ath11k] [ 51.603165] drv_start+0x38/0x60 [mac80211] [ 51.610110] ieee80211_do_open+0x29c/0x7d0 [mac80211] [ 51.617945] ieee80211_open+0x60/0xb0 [mac80211] [ 51.625311] __dev_open+0x100/0x1c0 [ 51.631420] __dev_change_flags+0x194/0x210 [ 51.638214] dev_change_flags+0x24/0x70 [ 51.644646] do_setlink+0x228/0xdb0 [ 51.650723] __rtnl_newlink+0x460/0x830 [ 51.657162] rtnl_newlink+0x4c/0x80 [ 51.663229] rtnetlink_rcv_msg+0x124/0x390 [ 51.669917] netlink_rcv_skb+0x58/0x130 [ 51.676314] rtnetlink_rcv+0x18/0x30 [ 51.682460] netlink_unicast+0x250/0x310 [ 51.688960] netlink_sendmsg+0x19c/0x3e0 [ 51.695458] ____sys_sendmsg+0x220/0x290 [ 51.701938] ___sys_sendmsg+0x7c/0xc0 [ 51.708148] __sys_sendmsg+0x68/0xd0 [ 51.714254] __arm64_sys_sendmsg+0x28/0x40 [ 51.720900] invoke_syscall+0x48/0x120 Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3 Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Fixes: 840c36fa727a ("ath11k: dp: stop rx pktlog before suspend") Signed-off-by: Johan Hovold Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220517103436.15867-1-johan+linaro@kernel.org Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath11k/core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c index 28de2c7ae899..473d92240a82 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -476,23 +476,23 @@ static int ath11k_core_pdev_create(struct ath11k_base *ab) return ret; } - ret = ath11k_mac_register(ab); + ret = ath11k_dp_pdev_alloc(ab); if (ret) { - ath11k_err(ab, "failed register the radio with mac80211: %d\n", ret); + ath11k_err(ab, "failed to attach DP pdev: %d\n", ret); goto err_pdev_debug; } - ret = ath11k_dp_pdev_alloc(ab); + ret = ath11k_mac_register(ab); if (ret) { - ath11k_err(ab, "failed to attach DP pdev: %d\n", ret); - goto err_mac_unregister; + ath11k_err(ab, "failed register the radio with mac80211: %d\n", ret); + goto err_dp_pdev_free; } ret = ath11k_thermal_register(ab); if (ret) { ath11k_err(ab, "could not register thermal device: %d\n", ret); - goto err_dp_pdev_free; + goto err_mac_unregister; } ret = ath11k_spectral_init(ab); @@ -505,10 +505,10 @@ static int ath11k_core_pdev_create(struct ath11k_base *ab) err_thermal_unregister: ath11k_thermal_unregister(ab); -err_dp_pdev_free: - ath11k_dp_pdev_free(ab); err_mac_unregister: ath11k_mac_unregister(ab); +err_dp_pdev_free: + ath11k_dp_pdev_free(ab); err_pdev_debug: ath11k_debugfs_pdev_destroy(ab); -- 2.35.1