Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3714926pxb; Mon, 24 Jan 2022 16:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvT0FpjDyqQvsvL+pysxYkjC7i2zPH4qdZ7z44FNDZFP0hB1Dzpp3EZCK5gTpWFWR9dkF+ X-Received: by 2002:a17:902:c946:b0:14b:6728:4d79 with SMTP id i6-20020a170902c94600b0014b67284d79mr3105828pla.17.1643069308509; Mon, 24 Jan 2022 16:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069308; cv=none; d=google.com; s=arc-20160816; b=jrpBoNs9UDkM5ej3v8llVQsYyhKDmwAmBg39oIpZTtjfsv5ca4ewjyGBPuovEjNLeI yixlssp6135Am2ssueLqwOOEf2iyytRrERaaz7nKlXWBlPAMWVf2mKeAN4eoh0Xg46cS PWO896Aejte8ovggoZvZMjph3n3M3kY2n8z6AIvt8HZwHZykKafMdmDX1vR52ENN818H 7bAMvmIf1OhXcbhV4Ir4AP6DROfwuTHN7zyjp961eLBcucQZF/2aRhbZ/ASz0C/zKWgA gsXciPu8SQercTz1SBnyNaOZm1KLfUfJX1PctTt/ozssUlWZDaWplJMn5FhOqlBLQBp4 CAyQ== 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=+zQgj2UzHcCvhvBMtZgho4RL9lGuNpaQb6iem62CHtg=; b=HxWSbQ8ZJAwU5kJ4j7xIYFwDTUnUWoYhzRVFifPf+tBESI+m2N6KCE6dOjVznExDZV /ZtE+F4gwE1Hhp7/kP5oi0CLbaiCe9TGrkUOQalmi+NdGJx8e5cOftM9DVyNRpf5rPiS /EV4wwoyFxXYmfZXd6EqqnoZOEBi6Qh16kCpwuPupQOA46tEJypCxnFOi9gS1vsW0wR7 F1A3iLKzwjLJQCiOtZ7iL7LbtDolbMEucEPP3cG2XrTSwbOhfQWFgwFI5siUyT7tNYB/ a8CP/qfmyABR8odQ6rye0g8A0HnM7hyR7E4MbKTEoaXnuMVmXhb/jf5RUK2Rj1gw5Oik Vlsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nFOTfOz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x12si13983090pga.234.2022.01.24.16.08.15; Mon, 24 Jan 2022 16:08:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b="nFOTfOz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2369249AbiAYABS (ORCPT + 99 others); Mon, 24 Jan 2022 19:01:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1847039AbiAXXSV (ORCPT ); Mon, 24 Jan 2022 18:18:21 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61DDC06F8D7; Mon, 24 Jan 2022 13:26:43 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id AC560B81218; Mon, 24 Jan 2022 21:26:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE852C340E4; Mon, 24 Jan 2022 21:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059601; bh=xaOjFriQ6amaUUYsrE142p7G3EPJVhpiLBHT/0meCKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nFOTfOz/V69nN7vZgZ1AZ/i/S2GX9gJcpajAaWEfxHEvSyY1p1/PiMN0ZqFYBDK/6 rMWXvIYX+Kjd2xvD4nxv1wkKsvT56wGHShTr+673jMofdzbbblwzh9Hlp/129k9VCw Ejd+3SirqTmF4UP4FS39Bu/ADK6OLdXcbb9iJ5/I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.16 0671/1039] mt76: connac: fix a theoretical NULL pointer dereference in mt76_connac_get_phy_mode Date: Mon, 24 Jan 2022 19:41:00 +0100 Message-Id: <20220124184147.929924729@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit c9dbeac4988f6d4c4211b3747ec9c9c75ea87967 ] Even if it is not a real bug since mt76_connac_get_phy_mode runs just for mt7921 where only STA is supported, fix a theoretical NULL pointer dereference if new added modes do not support HE Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index a5857a788da50..7733c8fad2413 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -1180,7 +1180,7 @@ mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, if (ht_cap->ht_supported) mode |= PHY_MODE_GN; - if (he_cap->has_he) + if (he_cap && he_cap->has_he) mode |= PHY_MODE_AX_24G; } else if (band == NL80211_BAND_5GHZ || band == NL80211_BAND_6GHZ) { mode |= PHY_MODE_A; @@ -1191,7 +1191,7 @@ mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, if (vht_cap->vht_supported) mode |= PHY_MODE_AC; - if (he_cap->has_he) { + if (he_cap && he_cap->has_he) { if (band == NL80211_BAND_6GHZ) mode |= PHY_MODE_AX_6G; else -- 2.34.1