From patchwork Wed Apr 17 08:31:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1086848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44kb7b6MHlz9s4Y; Wed, 17 Apr 2019 18:31:55 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hGfyx-0003WX-6d; Wed, 17 Apr 2019 08:31:51 +0000 Received: from mail-pf1-f193.google.com ([209.85.210.193]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1hGfyv-0003Vl-4i for kernel-team@lists.ubuntu.com; Wed, 17 Apr 2019 08:31:49 +0000 Received: by mail-pf1-f193.google.com with SMTP id t21so11766351pfh.2 for ; Wed, 17 Apr 2019 01:31:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G18GYNbhQSgkoEsP+O/QUZh1Hnq7MjoPSvQcz8xLu4s=; b=W+P814I/rUl6deXghuUe+EgcqYNnePA7Hxok0pRc6gfGjYMAMrhv+b44+MFuTILMc7 CkWyq1Joxxi2nfWimNMhJYx+r3tZjegrSLX156f7HcaiW4yfZsXsw/pU+fgpFNpY4cGX t+luV0V5YZKXWB55mtgcmcDXe6WN1uJ28ry64q9ZAWBhNjODjmvt8ssNXVV9mifvw8Ww 1bMKwkO04eNHF2dD6WoQNGWW7G5VjpXsl3mEG7HgWGracRkFuwO/Fnh7cjT1cddSRdO3 9KNe5ol78Wp0Kj6dsYTeoyxvwsRFj1+PEMHDV8G+91NWA1lsRLYlGIvxNgq2DTG7Rkti AOVA== X-Gm-Message-State: APjAAAV1JYcXVwSwbPeaxG4IgN9N/XlEK8E25HDCqQmFJVx4ruyn7efo 729sKj7Hp04ru1/UU/fyP1BkupxF X-Google-Smtp-Source: APXvYqwb/Lq+VCsTHTc1oiISd30buxj15KGqnOm9w1bYqAp8rdispNs+ZBXuvxM57SAyR91tEMpoaQ== X-Received: by 2002:a63:d349:: with SMTP id u9mr1984306pgi.83.1555489907489; Wed, 17 Apr 2019 01:31:47 -0700 (PDT) Received: from momoga.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id m23sm81048601pfa.117.2019.04.17.01.31.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 01:31:46 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1][SRU][B] mac80211_hwsim: Timer should be initialized before device registered Date: Wed, 17 Apr 2019 16:31:11 +0800 Message-Id: <20190417083112.25520-2-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190417083112.25520-1-vicamo.yang@canonical.com> References: <20190417083112.25520-1-vicamo.yang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Vasyl Vavrychuk BugLink: https://bugs.launchpad.net/bugs/1825058 Otherwise if network manager starts configuring Wi-Fi interface immidiatelly after getting notification of its creation, we will get NULL pointer dereference: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] hrtimer_active+0x28/0x50 ... Call Trace: [] ? hrtimer_try_to_cancel+0x27/0x110 [] ? hrtimer_cancel+0x15/0x20 [] ? mac80211_hwsim_config+0x140/0x1c0 [mac80211_hwsim] Cc: stable@vger.kernel.org Signed-off-by: Vasyl Vavrychuk Signed-off-by: Johannes Berg (cherry picked from commit a1881c9b8a1edef0a5ae1d5c1b61406fe3402114) Signed-off-by: You-Sheng Yang --- drivers/net/wireless/mac80211_hwsim.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 7d4e8f03ceefc..39f64cbd6f975 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -2703,6 +2703,10 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); + tasklet_hrtimer_init(&data->beacon_timer, + mac80211_hwsim_beacon, + CLOCK_MONOTONIC, HRTIMER_MODE_ABS); + err = ieee80211_register_hw(hw); if (err < 0) { pr_debug("mac80211_hwsim: ieee80211_register_hw failed (%d)\n", @@ -2727,10 +2731,6 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, data->debugfs, data, &hwsim_simulate_radar); - tasklet_hrtimer_init(&data->beacon_timer, - mac80211_hwsim_beacon, - CLOCK_MONOTONIC, HRTIMER_MODE_ABS); - spin_lock_bh(&hwsim_radio_lock); list_add_tail(&data->list, &hwsim_radios); spin_unlock_bh(&hwsim_radio_lock);