Message ID | 20230516074554.1674536-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp255066vqo; Tue, 16 May 2023 01:05:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7bbR1vf2MrS1IJ7lrEP7tkAtNHw00+hh56e6jdNKKuZ0s+YQpb317ydgGnKnDkh3foLQPU X-Received: by 2002:a17:902:ea8b:b0:1a0:50bd:31a8 with SMTP id x11-20020a170902ea8b00b001a050bd31a8mr40416064plb.26.1684224356659; Tue, 16 May 2023 01:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684224356; cv=none; d=google.com; s=arc-20160816; b=HZyJogW9nuQUm+CpWSJmfvuyAJ9HedTljFEl8tc9proBhdj5tqOTqQqkjLF/JbZyAJ RAxEUu+srKBpkPT6cn9COUnOh2ZBtsqE+wEeHLRzMSrbq8SaKZBBu22SYYb+xAwbU6f7 F9YxPaBGGfMKnovBXwOC9Blyu3U5hD5WvWy6x/GquuuVG0Ng1OVkejCqVRtAVbo9ms9h 6klg98j8rnNceJ46tYHvecA5yiMmnUS04NpGYCZ/0jOotWtKSZWI5khCJFWIQ0eVo2DU QOijpw0ovd6r9SbUXWhUaVRDODCMAZKyZ+v/VacTqzACVkdZX53OIz00q7B00WkZa20x 3iNA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Hzhq2e8PVhFVZ2SPOG8NzqYoZ2H8ZlyME3XL/awojHQ=; b=H7i6BrpKK7nDFdGowNnPaFyEiVTT/oSAYkaVVnee2hQhLmrVkB/Ra6IOsMDcaWoFPo S2dyjC6cPTox5X/dUuH6gcXHN+qGsggj+Oca5W6Z4Om9BPP6Tj0kua4B2ZPNFjlnDpsG N9aq1ME6+9E2+jtsKTDCwIEomEtm8GCsVMPaP3bfC0EeE9C8AkT8C48Qdyv9C5IweGIx ESRE41QVcVpgzBOP8+8U2m/vrSAael5pBEBNiEdhT11IFKM+W3Hb6j6WNA3GDQ+/5Dxb +uneYtrNgM5HxAhoulCpfbkr/VPv21kGnW/f6CgmQHsbni9a1iAO/vpSuLiDlHmysTBe 9GdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c4Tkzftt; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a170902758200b001a9581bfb91si16456316pll.543.2023.05.16.01.05.44; Tue, 16 May 2023 01:05:56 -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=@kernel.org header.s=k20201202 header.b=c4Tkzftt; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231458AbjEPHqH (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Tue, 16 May 2023 03:46:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbjEPHqF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 16 May 2023 03:46:05 -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 8F2D3449B; Tue, 16 May 2023 00:46:01 -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 18E3662850; Tue, 16 May 2023 07:46:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CE33C433D2; Tue, 16 May 2023 07:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684223160; bh=DWVQGg8BOQg1TC5mQhyL5M5QVn3UeUKSLvymNtkvcT4=; h=From:To:Cc:Subject:Date:From; b=c4TkzfttZpQk0Ptc+5OqMy617FPzeTD+h9izO2F78CbvIexZDfGN86mXf7dEkoxa9 h+lGw7DZfar/rMhiBdMV4WCAtrfSzoEHviL4BQsivRZF2nzHS6ZauNO62pFMsNyyFL AteyHMEc3rleqpNvRDnhzy77+P+WDF7n10KIosEBEWyuPIDs9/UsoqZh4aj3MMuZza bJM3xkdKlERWL9lHGePfDyU0EOfg70bLlL5XYtvIJalyVwTF6WxBKZ/z8Zb6jT28xc VAay31rGQE1qLGmb8S1LUUoYgAhMPhbg/2H3rsouC0ngqss5jB13ErcvDHW8pvuGMV nc42AQEJ4z8Hg== From: Arnd Bergmann <arnd@kernel.org> To: Kalle Valo <kvalo@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, linux-wireless@vger.kernel.org, b43-dev@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] wifi: b43: fix incorrect __packed annotation Date: Tue, 16 May 2023 09:45:42 +0200 Message-Id: <20230516074554.1674536-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766037238857408532?= X-GMAIL-MSGID: =?utf-8?q?1766037238857408532?= |
Series |
wifi: b43: fix incorrect __packed annotation
|
|
Commit Message
Arnd Bergmann
May 16, 2023, 7:45 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> clang warns about an unpacked structure inside of a packed one: drivers/net/wireless/broadcom/b43/b43.h:654:4: error: field data within 'struct b43_iv' is less aligned than 'union (unnamed union at /home/arnd/arm-soc/drivers/net/wireless/broadcom/b43/b43.h:651:2)' and is usually due to 'struct b43_iv' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] The problem here is that the anonymous union has the default alignment from its members, apparently because the original author mixed up the placement of the __packed attribute by placing it next to the struct member rather than the union definition. As the struct itself is also marked as __packed, there is no need to mark its members, so just move the annotation to the inner type instead. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/wireless/broadcom/b43/b43.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, May 16, 2023 at 09:45:42AM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > clang warns about an unpacked structure inside of a packed one: > > drivers/net/wireless/broadcom/b43/b43.h:654:4: error: field data within 'struct b43_iv' is less aligned than 'union (unnamed union at /home/arnd/arm-soc/drivers/net/wireless/broadcom/b43/b43.h:651:2)' and is usually due to 'struct b43_iv' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] > > The problem here is that the anonymous union has the default alignment > from its members, apparently because the original author mixed up the > placement of the __packed attribute by placing it next to the struct > member rather than the union definition. As the struct itself is > also marked as __packed, there is no need to mark its members, so just > move the annotation to the inner type instead. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Simon Horman <simon.horman@corigine.com>
On Tue, 16 May 2023 09:45:42 +0200 Arnd Bergmann <arnd@kernel.org> wrote: > b43_iv { union { > __be16 d16; > __be32 d32; > - } data __packed; > + } __packed data; > } __packed; > > Oh, interesting. This has probably been there forever. Did you check if the b43legacy driver has the same issue? Acked-by: Michael Büsch <m@bues.ch>
On Tue, May 16, 2023, at 19:12, Michael Büsch wrote: > On Tue, 16 May 2023 09:45:42 +0200 > Arnd Bergmann <arnd@kernel.org> wrote: > >> b43_iv { union { >> __be16 d16; >> __be32 d32; >> - } data __packed; >> + } __packed data; >> } __packed; >> >> > > Oh, interesting. This has probably been there forever. > Did you check if the b43legacy driver has the same issue? I had not checked, but I see that it does have the same bug. I only sent this one because the build bot (incorrectly) blamed one of my recent patches for a regression here. Which reminds me that I was missing: Reported-by: kernel test robot <lkp@intel.com> Link: https://lore.kernel.org/oe-kbuild-all/202305160749.ay1HAoyP-lkp@intel.com/ Should I resend this as a combined patch for both drivers? Arnd
On Tue, 16 May 2023 19:45:16 +0200
"Arnd Bergmann" <arnd@arndb.de> wrote:
> Should I resend this as a combined patch for both drivers?
I think that would be fine, yes.
Thank you for checking.
On 5/16/23 02:45, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > clang warns about an unpacked structure inside of a packed one: > > drivers/net/wireless/broadcom/b43/b43.h:654:4: error: field data within 'struct b43_iv' is less aligned than 'union (unnamed union at /home/arnd/arm-soc/drivers/net/wireless/broadcom/b43/b43.h:651:2)' and is usually due to 'struct b43_iv' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] > > The problem here is that the anonymous union has the default alignment > from its members, apparently because the original author mixed up the > placement of the __packed attribute by placing it next to the struct > member rather than the union definition. As the struct itself is > also marked as __packed, there is no need to mark its members, so just > move the annotation to the inner type instead. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/net/wireless/broadcom/b43/b43.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/broadcom/b43/b43.h b/drivers/net/wireless/broadcom/b43/b43.h > index 9fc7c088a539..67b4bac048e5 100644 > --- a/drivers/net/wireless/broadcom/b43/b43.h > +++ b/drivers/net/wireless/broadcom/b43/b43.h > @@ -651,7 +651,7 @@ struct b43_iv { > union { > __be16 d16; > __be32 d32; > - } data __packed; > + } __packed data > } __packed; This change works on a BCM4306 and BCM4318=. Tested-by: Larry Finger <Larry.Finger@lwfinger.net> To answer Michael's question, b43legacy has the same issue. Larry Larry
diff --git a/drivers/net/wireless/broadcom/b43/b43.h b/drivers/net/wireless/broadcom/b43/b43.h index 9fc7c088a539..67b4bac048e5 100644 --- a/drivers/net/wireless/broadcom/b43/b43.h +++ b/drivers/net/wireless/broadcom/b43/b43.h @@ -651,7 +651,7 @@ struct b43_iv { union { __be16 d16; __be32 d32; - } data __packed; + } __packed data; } __packed;