From patchwork Wed Oct 19 08:26:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp212065wrs; Wed, 19 Oct 2022 02:06:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM79LMz2yHspquq8+RwaPstlcacx0s2T77NWKiTq9SdfeWW0vQ8z5cuQojI21619RtSSSv+0 X-Received: by 2002:a17:906:cc10:b0:78d:f741:9d87 with SMTP id ml16-20020a170906cc1000b0078df7419d87mr5820503ejb.295.1666170398039; Wed, 19 Oct 2022 02:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170398; cv=none; d=google.com; s=arc-20160816; b=Ohf5CFIc25d8IPk3O+x5Dy+NId6h1ruv0gh0mZCT0z/Pv0WMlDYBW1PVROySbQAUS9 Yh1+TvDKLJ4zr0TJGPaURs4C6oFTOItYgoE+/NhxbGqWJX9K1ZC4kq1jq3lnGanAa38T Rb/gBf+qGzCCusje1nGdkl5I28XpdyS1UOg9Uu3FSSW7hT7Y0cKlZb7AS6EPWJ696N10 bTh0pZllEsHbkSlLj9LpCrnLefuMqxS7B/gvf9WWNrgeABDcVdTd9We6W6q4LZMYFSRu DrTJUGOEMEZAJZ8DXR2/X+p90ExFOgz2VAi9IM4VjiQI+2ZPcFN28ObANSXNMvq5QemV A/Zw== 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=lqmgkvzfGbiu/mtdanLwq7B+xk4ma/cyc0UEVphaLwA=; b=sYX+a0mrtBBkWjIW7gkz2KXV19IwB/ZM8qc8tfq7d/GVbPup+YVw1uMl48hXxMqrqC eaFtKzaIYU2zJwXrimOvmcvIg3zKSBb9ZLYMsFu8hYVBCvtAE8vETHHmaUDn3MoAAUeB Phr1NoIkWQ+5h5dmygnuNSUZQRIXY8Wug66NdB0kM6VO2BKjmW3qZyOdDtb9YwAH6IUf UTotQ6PBa4Wqcioucg4rbS8hiWT8oSy7DvpPCfT9//BzjDgZn4H2B7LXGT7Q9/j44wSW ktfA6jU7IhKZQtGW2zTHEsF04EKduUhnaC2qTHRnOifs8kB0QqFJZ1WFSifDV9zZJAob 10iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gym8csTl; 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 dt19-20020a170907729300b0078168566b26si14457087ejc.356.2022.10.19.02.06.06; Wed, 19 Oct 2022 02:06:38 -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=Gym8csTl; 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 S232004AbiJSI5T (ORCPT + 99 others); Wed, 19 Oct 2022 04:57:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbiJSI4f (ORCPT ); Wed, 19 Oct 2022 04:56:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34E3B193DC; Wed, 19 Oct 2022 01:52:35 -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 AB18C61866; Wed, 19 Oct 2022 08:50:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC0E0C433C1; Wed, 19 Oct 2022 08:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169456; bh=kwElycgk0G90REzPfSoa4Yxr7/w7BcPRL2CXRgWe54U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gym8csTlV+Opwmw6lrQ8a8KKD2MuWRRvDGGfqbZROyReNd9FuBwBUgD+BK9+DJf6a 2rVFFCEHblC4H3LxVGZhgfUjwxCfkZ/ZPsA2Jz8cRKG0OM4VIo6j430Rw2zlTWD8rb VDpNaw2ML3nD4Vq16UsM4lOZ4AoSg4+7kUB6fhMI= 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 6.0 284/862] wifi: mt76: mt7915: fix possible unaligned access in mt7915_mac_add_twt_setup Date: Wed, 19 Oct 2022 10:26:11 +0200 Message-Id: <20221019083302.553066406@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106291193558660?= X-GMAIL-MSGID: =?utf-8?q?1747106291193558660?= 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 4ddcd3afa428..49aa5c056063 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -2071,8 +2071,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); @@ -2122,8 +2123,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); }