Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3701937pxb; Mon, 24 Jan 2022 15:47:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyB7JGY/xkg/Zrufk0XYwxxpgIUQqLE2iWTU8PqJ6SDZ84wApxql1XjBuWdNaBG3UlWmWuV X-Received: by 2002:a05:6a00:2494:b0:4c9:f16b:3e37 with SMTP id c20-20020a056a00249400b004c9f16b3e37mr4001340pfv.29.1643067965775; Mon, 24 Jan 2022 15:46:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067965; cv=none; d=google.com; s=arc-20160816; b=EPAD7+dmevdByNCfgR2nZKr26FKRsjuim460cAFuB9ohsEylvKXX2M8svAgMTjF7tl jQFIVdikWFUjrufRkwmAI7Ea3wvU6qfbeM5pmk4J5lgmrhN+h85MMBlirWXzcS9u9QXo jyxGkk2Ua+7Sq1Jmn/SQu0jxgXVFkrwXG3cfggm8za+CiNqHhQQl7T+7RiLISATZPjoB fNpyGf2e5ZJ14wrv7p1lRj0jUevtu5yEclq1UXR2SHDHTA3Mtumxtr9Mzzs9W2Xfzd9P H3mqsKBwAVFcXV/bAt4WqJPUauZ3xkaAX/Z205+GB+Z9a/C0eA1V5Oqb8P0VTJHVbpes e7Xg== 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=5bKZDEWLmMyWyv/vKWQbzzfdOV1rpsqJ7M5tS87BU18=; b=WxQcchAowcKRPzaliCEY3KADjIlEGZU3PUJkz70Br+sTIrFPf+91HUJ4scz/o6ZCvs ZwagPzCL8xrp3aq+kX4AIkdfY5jP4VLn2lB6IzhpdO3Uq8ChfJq+LR8OZJ5yUpxSDYmI DDcbYyPLHvrxE/+nvNR5mynDY3NBE+pWEakNEmI8875ZQFOkYnrVN/vMBTAfP+kYpM3W Gm4BTLV3E6qiSFj4FAG+mB8Vx7M8+LwhcmoAD6QtBdyp4zmc9a/tCK7V7DyfZtuRYVIc dXJwDE5Lddipc3z+TLND2E4oF4TvHhKyUienNo/WkWJWePhN6DyNOcZCQV4IiOeWxJII ixFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AZwb7YSc; 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 t3si4040553pfg.55.2022.01.24.15.45.53; Mon, 24 Jan 2022 15:46:05 -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=AZwb7YSc; 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 S2360477AbiAXXgv (ORCPT + 99 others); Mon, 24 Jan 2022 18:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351118AbiAXWxj (ORCPT ); Mon, 24 Jan 2022 17:53:39 -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 6A111C0EE12B; Mon, 24 Jan 2022 13:08:29 -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 275DFB8123D; Mon, 24 Jan 2022 21:08:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20201C340E5; Mon, 24 Jan 2022 21:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058506; bh=7kR9ewpZ7hOXX/Afq2CPiSJiQAxrzpCzuz/GkMjpraY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AZwb7YScHIfHQJEPq6tT1sGRM9cbfQdpNR2GRiczGyWfwBqajvfReSUJ2/sAGAhx1 xYMety0mYuUFssKyVymBzJlWpHLP+sQget4MSzshQ5zb8PB0v8f7vWlZt69cN0ox+M RZdgEcRmc5wOLv16uiqLZ4qTh43teYe2JwyYIuDs= 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 0312/1039] mt76: mt7921: fix possible NULL pointer dereference in mt7921_mac_write_txwi Date: Mon, 24 Jan 2022 19:35:01 +0100 Message-Id: <20220124184135.792115428@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 ec2ebc1c5a5ce49538fa78108c53eaf722eee908 ] Fix a possible NULL pointer deference issue in mt7921_mac_write_txwi routine if vif is NULL. Fixes: 33920b2bf0483 ("mt76: add support for setting mcast rate") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index db3302b1576a0..321d9f1d3f865 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -903,7 +903,7 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi, mt7921_mac_write_txwi_80211(dev, txwi, skb, key); if (txwi[2] & cpu_to_le32(MT_TXD2_FIX_RATE)) { - int rateidx = ffs(vif->bss_conf.basic_rates) - 1; + int rateidx = vif ? ffs(vif->bss_conf.basic_rates) - 1 : 0; u16 rate, mode; /* hardware won't add HTC for mgmt/ctrl frame */ -- 2.34.1