Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1372994pxb; Fri, 21 Jan 2022 16:52:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5Kyyjo5yXyAlE83A3KmCh2JPzfQ0yN/UiAOtAaR/ju1Z1GNyItBTJv0zj/J0U3o9qsv22 X-Received: by 2002:a05:6a00:14cf:b0:4c7:6139:b7b4 with SMTP id w15-20020a056a0014cf00b004c76139b7b4mr3409889pfu.37.1642812736546; Fri, 21 Jan 2022 16:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642812736; cv=none; d=google.com; s=arc-20160816; b=xm+XyxZ4Yv0IwxzVC/o7vwkuJ9DYsV1+8OnkW4TPv/rmLFR4FkzV8bJkCCRALoEzLR eFuNW0XxqQsr5+AAx5gQ9UnLVLDOCdUV5puzbdC/ef4NVmhl3lrGcPw42qqMXv3ma7bB Mihv35qkfdFRbXBzgpJlqcjKrNcAPRAzzKwCAujX8QqNzxw5XGvFOizC1GQ6whLS0MuO uopNHr9rtcZ3CFKXVOVu0ogekL30ovnaKi4M23EhnGWqaFhiHuv/O66zaf1+rFI1q3Fj 7PevEs0gGKKXUFcqE9fXdRC2L0RCMdrcmo+oV7zntR96G62qyF3/JMlXzcObTP6kmQNI l34w== 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:dkim-signature; bh=p1in7D2MoPPm603YyrrTr2s6zVMfG0P250uqSYygmeI=; b=n5Wrf+an8NSC3UI0X9DkdVRBDAdld007xam1KB38019Cmoz8Latt4oK/KDXS6TQWm5 bBIuw7lo8XqYFcVot72LYEW8maF0stp/CEIFvU9HZpvDTMjNLlYyFpeNY8RU8kZoXK1+ VIpMGS3Hty/d+DBF0wdzlMuRyB3hf+uaw9v05esaJQ1cJpuMSGleA03EUaUlqJwnsdEI 49Ut8J1Pk1Qcym9rpPmWGbc/RPQ7AssGhYuJJFKQcrI1L1zc54jNlaD2cxHTCIdRPlKA WQf9KTHMjmg/XLPx+6dhirpq9jYOqGcG+SwYwYhIiZ+rWBzfimJpkPhBFvmbYP3As0v8 Co0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=h5S0Jr6F; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si7671552pgb.633.2022.01.21.16.52.08; Fri, 21 Jan 2022 16:52:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=h5S0Jr6F; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345305AbiAULka (ORCPT + 70 others); Fri, 21 Jan 2022 06:40:30 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:52862 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiAULka (ORCPT ); Fri, 21 Jan 2022 06:40:30 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 332651F888; Fri, 21 Jan 2022 11:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1642765229; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=p1in7D2MoPPm603YyrrTr2s6zVMfG0P250uqSYygmeI=; b=h5S0Jr6FZwY202+6mTdu9nNbF+F26Jl2zNoQmfahKHaPL88xWfJd9P7RsicQXk8sfM+CVC k3EBvIUVrExSjqmvYCvhdXzPY0a0dcwvepPCjkztMWP0JwWQMnBXHEvJXir+asDOovxKPa PfsZwKNUsl6pBIi8x83ZYGCAcZtUcpU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1642765229; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=p1in7D2MoPPm603YyrrTr2s6zVMfG0P250uqSYygmeI=; b=IOtP3Dt8foBoh38dhybtf3hNkVwT5gsFuSCgeSs2nfKxj6LlDx8rohZRW8FgmpKMn70JRy 6S6nKX+lfZ6XP2Dw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 29FB5A3B83; Fri, 21 Jan 2022 11:40:29 +0000 (UTC) From: Takashi Iwai To: Luca Coelho Cc: Johannes Berg , Oliver Neukum , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] iwlwifi: mvm: Don't call iwl_mvm_sta_from_mac80211() with NULL sta Date: Fri, 21 Jan 2022 12:40:24 +0100 Message-Id: <20220121114024.10454-1-tiwai@suse.de> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The recent fix for NULL sta in iwl_mvm_get_tx_rate() still has a call of iwl_mvm_sta_from_mac80211() that may be called with NULL sta. Although this practically only points to the address and the actual access doesn't happen due to the conditional evaluation at a later point, it looks a bit flaky. This patch drops the temporary variable above and evaluates iwm_mvm_sta_from_mac80211() directly for avoiding confusions. Fixes: d599f714b73e ("iwlwifi: mvm: don't crash on invalid rate w/o STA") Signed-off-by: Takashi Iwai --- Corrected the subject and the description from https://lore.kernel.org/r/20220121111418.9144-1-tiwai@suse.de drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c index 6fa2c12f7955..4d1ddca73fb0 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c @@ -318,15 +318,14 @@ static u32 iwl_mvm_get_tx_rate(struct iwl_mvm *mvm, /* info->control is only relevant for non HW rate control */ if (!ieee80211_hw_check(mvm->hw, HAS_RATE_CONTROL)) { - struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); - /* HT rate doesn't make sense for a non data frame */ WARN_ONCE(info->control.rates[0].flags & IEEE80211_TX_RC_MCS && !ieee80211_is_data(fc), "Got a HT rate (flags:0x%x/mcs:%d/fc:0x%x/state:%d) for a non data frame\n", info->control.rates[0].flags, info->control.rates[0].idx, - le16_to_cpu(fc), sta ? mvmsta->sta_state : -1); + le16_to_cpu(fc), + sta ? iwl_mvm_sta_from_mac80211(sta)->sta_state : -1); rate_idx = info->control.rates[0].idx; } -- 2.31.1