From patchwork Sat Oct 22 07:22:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1093417wrr; Sat, 22 Oct 2022 00:57:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6s85UvesdeAwyXP5FLzMIOIxNth1UX9y3sWHy8vIe0rpH3n1f6VTj5H+YZnQgPB4powrwF X-Received: by 2002:a63:e14c:0:b0:439:2e24:e014 with SMTP id h12-20020a63e14c000000b004392e24e014mr19185221pgk.173.1666425429662; Sat, 22 Oct 2022 00:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425429; cv=none; d=google.com; s=arc-20160816; b=t5yPMdUfqo1Hbun5192uBS4VkhmR1XK/THgOHPqUh+9Z8Z/l/NAE88GwBkF3JzHCfQ jSCXawheAb6KAyKne0A481oAfdzMVZdEowXm6K84yegj/BfsUW1vekD8icVFhqvGbYZr bS780/vYK1dfIInBbz0WHoef9Ay0OxYXt1XTGgFzthuuHY0uvQWRoSyazJK1djd4pu0F UhaaG0iZeNqYtJn6H4JCgSU7gv1ujss60mFMaEHBgIXLyBQK4KrFVLXPiHDd413USPUe wqYS9CxnOFwfTpqhkZJac3FsGt4HClMSiI+tzF/x5BSQ56Q9w998fc4O2sBaDENam7Oo vVVQ== 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=2BQWTQd2jrsaYmKsh1EldvjUkEQm0qc3f+NBU6AEYx4=; b=tdQdNZWiei/Tay+sPQWaJBQ2m6KwMCJoxKyc7xBsP1kzft4BJbR96gaYk/NiwbuAr0 igCCI2r4Q1p3w9K/SiLtMm5I/UnL8G9K4ynBZIa7GXc6Vo015xVvJbJR1cOz1MNzrSgO GPU+4YcIMh+1N0N/MbUKBfi1e4KvE1TDk2ORF2gTaJvcUwICCf8e/gGCQL+uhTNBWlG2 NpVEzOAmSyCsP7rqyctBm18o/I0LESxl9fAeiHU7BmmAZIsU8ZxjpIT0uRp3k5eutTrN QPv4RGKKwapa5cKzjWmvZIlijqMYqFg1CvI0tjnalMhobPq3T+RoIyuOlST0zQAwFlCt PdUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=128Mk6uG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pi5-20020a17090b1e4500b00212ca8e7457si6059040pjb.133.2022.10.22.00.56.57; Sat, 22 Oct 2022 00:57:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=128Mk6uG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232113AbiJVH4k (ORCPT + 99 others); Sat, 22 Oct 2022 03:56:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbiJVHwv (ORCPT ); Sat, 22 Oct 2022 03:52:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C942CA7DC; Sat, 22 Oct 2022 00:46:55 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 3988B60B3B; Sat, 22 Oct 2022 07:45:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 192F7C433D6; Sat, 22 Oct 2022 07:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424700; bh=VRLqewPZnRfvRb2gTusmvVhdK4472AhYpCvXWsyNu4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=128Mk6uGJWbDuGB2cdAvsIZmO90vMkS2ydUOCL+hldbFIYAV28W9GGp23Uvj+kWPQ PgUT8mnVxH+Rdnrs+Sgy6zoEHmYYkSqeUbV9E5rRIXe/dFfY9ElUkq6CQoy3Quzv4m oADV9bh54Rb3FBhneWC99L0clif9g7lgAGpM7dbs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.19 244/717] wifi: mt76: mt7915: fix possible unaligned access in mt7915_mac_add_twt_setup Date: Sat, 22 Oct 2022 09:22:03 +0200 Message-Id: <20221022072458.124221443@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747373711311586083?= X-GMAIL-MSGID: =?utf-8?q?1747373711311586083?= From: Lorenzo Bianconi [ Upstream commit 3d9aa54355d863e5412a7e08180f50a8f1827b7f ] Fix possible unaligned pointer in mt7915_mac_add_twt_setup routine. Reported-by: kernel test robot Fixes: 3782b69d03e71 ("mt76: mt7915: introduce mt7915_mac_add_twt_setup routine") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 89f10bf885ba..4f3a3a88f086 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -2536,8 +2536,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, } flowid = ffs(~msta->twt.flowid_mask) - 1; - le16p_replace_bits(&twt_agrt->req_type, flowid, - IEEE80211_TWT_REQTYPE_FLOWID); + twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_FLOWID); + twt_agrt->req_type |= le16_encode_bits(flowid, + IEEE80211_TWT_REQTYPE_FLOWID); table_id = ffs(~dev->twt.table_mask) - 1; exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type); @@ -2587,8 +2588,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, unlock: mutex_unlock(&dev->mt76.mutex); out: - le16p_replace_bits(&twt_agrt->req_type, setup_cmd, - IEEE80211_TWT_REQTYPE_SETUP_CMD); + twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_SETUP_CMD); + twt_agrt->req_type |= + le16_encode_bits(setup_cmd, IEEE80211_TWT_REQTYPE_SETUP_CMD); twt->control = (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) | (twt->control & IEEE80211_TWT_CONTROL_RX_DISABLED); }