From patchwork Mon Jul 25 14:12:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 593433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C069C433EF for ; Mon, 25 Jul 2022 14:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235387AbiGYOMW (ORCPT ); Mon, 25 Jul 2022 10:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233550AbiGYOMU (ORCPT ); Mon, 25 Jul 2022 10:12:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D8FAE45 for ; Mon, 25 Jul 2022 07:12:19 -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 ams.source.kernel.org (Postfix) with ESMTPS id 46101B80ED4 for ; Mon, 25 Jul 2022 14:12:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98CD6C341C6; Mon, 25 Jul 2022 14:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658758337; bh=KcOUJaTeq05ZvYJ7XFjq2YKCE/UTQcJEfwvirsJZrIU=; h=From:To:Cc:Subject:Date:From; b=CKf1sA9aDLKa6SjUFvOcLWnaroPoO4l3eMRr/SmOGfQgU/UAPAi5O54+rtnDC4OiB TRpyFBA+pL0+Uz9sn9joBhvyNv5VgGtcmLOjE7d2uSXdJBXiaaWysPn7kD0FgmdxeE BVTwdy/ABlh1695rpcCiXPn9llZEXZlvI3A5uReJipF4JZzOvuyUEi5YsAvT2J/LV+ L0NZGSCNEcGDbhaErRMhBeE0QbBp7V2g7VI+EUgDF6Zlt3Bq/QiQ8GTWJ2fL12wNbx fyEqJImqpV0sMD3C62nS4Pu6gnMARG3tTytl9YTyqgz0bSY9bTQj3IjXHcS0jcVabo zISceQ7ne6xvg== From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH] mt76: connac: fix possible unaligned access in mt76_connac_mcu_add_nested_tlv Date: Mon, 25 Jul 2022 16:12:06 +0200 Message-Id: X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Fix possible unaligned pointer in mt76_connac_mcu_add_nested_tlv routine. Reported-by: kernel test robot Fixes: 25702d9c55dc5 ("mt76: connac: rely on le16_add_cpu in mt76_connac_mcu_add_nested_tlv") Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 6 ++++-- 1 file changed, 4 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 9b17bd97ec09..13d4722e4186 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -260,8 +260,10 @@ mt76_connac_mcu_add_nested_tlv(struct sk_buff *skb, int tag, int len, ntlv = le16_to_cpu(ntlv_hdr->tlv_num); ntlv_hdr->tlv_num = cpu_to_le16(ntlv + 1); - if (sta_hdr) - le16_add_cpu(&sta_hdr->len, len); + if (sta_hdr) { + len += le16_to_cpu(sta_hdr->len); + sta_hdr->len = cpu_to_le16(len); + } return ptlv; }