Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3022696pxj; Mon, 17 May 2021 15:49:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ79lqUb7S0wXld0sJuOZcLakpmTtGL3suEE9JgkXY9hk0kVUVZtXtq9Tk5+rC/ofRWjrS X-Received: by 2002:a02:c912:: with SMTP id t18mr2260109jao.100.1621291759843; Mon, 17 May 2021 15:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621291759; cv=none; d=google.com; s=arc-20160816; b=Vu9lJeMI7RO6Gtw41icEaPfK8zcOsF/pMvVBaOYKIb2yCZnRBkusKzKC2Oh6qDJHh0 gdwmarW7EJsx8FdRhuBDUbinwGRBz57Qpbc9KeTtmXV0q/jlhfaJytF1WfV+zJNTH1+w 8d30sxZL2Vp6ICJCdd49Ut4Z8HLxjU4GP1iIXflJsPLLgIklr60YGGXVHs92bsDBRk4F a/JBML7FQ389xCP7wE1+yMwH7JGU6rSfqZxNoZoUTSppwDuLUsawU2J5aT0/UoA6fzQi kiWMh2Yp0DDpzFp8lq/8yyEpok7v27mDDFNz34Pg4lcATdYuifu+/OcM/oXXfQHrhqPT /WUg== 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=Af5wXw868aWay1UzGMYuN+SekUqVV6keRWhrD4FB05E=; b=YNPb/abD7xLHURfXQrKsmqcNmxhUS8PJwK494sY76z+c4SIrZgz9HvH9Zi/ZbrQC27 YKGCA+Kd2dNZ0JfkmwmPPqNmd79A6FjZu7R2nw/Je1/S/sP3x2zm7s9FfnC3kgKKCyri Bsf3jzY51zs4/4x2qru0xidJsuK66O4AAjN0WoUEUImQtouNSLiENrwSa3uQu12EmSSM NEty/3gM8zn5RL3kfDze/5dAtWw3ba4vrTImC3t5aWAhe1HSksXPofNT3znajD8Mprqi QyuSBoAo/cCiBatEybRCrseKRs8vmimH+bLIAAi/Xj4wJqBGa/Hcbcm3FrNoXDPZBEsK tk/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WUbgSSX4; 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 l23si8794232jas.94.2021.05.17.15.48.51; Mon, 17 May 2021 15:49:19 -0700 (PDT) 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=WUbgSSX4; 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 S238652AbhEQOQM (ORCPT + 99 others); Mon, 17 May 2021 10:16:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:46438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238173AbhEQOMz (ORCPT ); Mon, 17 May 2021 10:12:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0AEBA613DA; Mon, 17 May 2021 14:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260492; bh=iOKA6xzjmNWup0nc0mCEE6Ox7/7RVKM49ZXrU/Gum0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WUbgSSX4vkVM3mgWTdR9qS5Bss3WyySpbUl5JxtWi8+LPCtM0vAXDdodD8RALTvK6 rCMt2B0PeWcKXxiyDpANEFgIOuwg4FxII4gndV4a4VuDdcih2MPiJDJWDcdrkH5twJ XJJnYJ9owYhzTkrxgRY+7Up5fYSsX4f4mdQZY4DU= 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.12 070/363] mt76: mt7921: fix key set/delete issue Date: Mon, 17 May 2021 15:58:56 +0200 Message-Id: <20210517140304.963905516@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 60468f7fd7072c804b2613f1cadabace8d77d311 ] Similar to the mt7915 driver, deleting a key with the previous key index deletes the current key. Rework the code to better keep track of multiple keys and check for the key index before deleting the current key Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- .../net/wireless/mediatek/mt76/mt7921/main.c | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index cd9fd0e24e3e..ada943c7a950 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -413,7 +413,8 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct mt7921_sta *msta = sta ? (struct mt7921_sta *)sta->drv_priv : &mvif->sta; struct mt76_wcid *wcid = &msta->wcid; - int idx = key->keyidx; + u8 *wcid_keyidx = &wcid->hw_key_idx; + int idx = key->keyidx, err = 0; /* The hardware does not support per-STA RX GTK, fallback * to software mode for these. @@ -429,6 +430,7 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (key->cipher) { case WLAN_CIPHER_SUITE_AES_CMAC: key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE; + wcid_keyidx = &wcid->hw_key_idx2; break; case WLAN_CIPHER_SUITE_TKIP: case WLAN_CIPHER_SUITE_CCMP: @@ -443,16 +445,23 @@ static int mt7921_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return -EOPNOTSUPP; } - if (cmd == SET_KEY) { - key->hw_key_idx = wcid->idx; - wcid->hw_key_idx = idx; - } else if (idx == wcid->hw_key_idx) { - wcid->hw_key_idx = -1; - } + mt7921_mutex_acquire(dev); + + if (cmd == SET_KEY) + *wcid_keyidx = idx; + else if (idx == *wcid_keyidx) + *wcid_keyidx = -1; + else + goto out; + mt76_wcid_key_setup(&dev->mt76, wcid, cmd == SET_KEY ? key : NULL); - return mt7921_mcu_add_key(dev, vif, msta, key, cmd); + err = mt7921_mcu_add_key(dev, vif, msta, key, cmd); +out: + mt7921_mutex_release(dev); + + return err; } static int mt7921_config(struct ieee80211_hw *hw, u32 changed) -- 2.30.2