From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA750C5516F for ; Fri, 31 Jul 2026 15:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=4lJnn4e7C9hE6wEWtqXYdtrs6SZibcqzJoHLR3d96n8=; b=xBOlC+QrN9sJv0TMgank2wNV3+ /GV7bZfXDYTLyZ8d7r/37lNCOYEnEqrAZDvIWWZ1Tm0thYTJvi9mt402bawD+Vqb7YCrcaZMCGUVz cC6Zwj3hPirTkA7R5QD5NmFHRvCkTzvNFwkxApMnR64gxZfdgsXdcT6GXg/hsX1OaXNQnzS+W3JPF fiYo/fLatXdb2qaQ8JKXifkcVUfbFvXH6wFdoqJtX4Lgwoe9p3VlHByHiVNH3+I1rgU/IHJWSJMiL Lh1ikqEZZnVSrVXrPfW+wcxs2nwqW9CJdsUrYwHSKgWClHmviF3k655W0BpsGQEYYcGiu13SCoWUz gN7R1eXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wppSz-0000000CveI-34Wk; Fri, 31 Jul 2026 15:48:09 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wppSy-0000000Cvdp-0Ww4; Fri, 31 Jul 2026 15:48:08 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 25F856004E; Fri, 31 Jul 2026 15:48:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5989B1F000E9; Fri, 31 Jul 2026 15:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785512886; bh=4lJnn4e7C9hE6wEWtqXYdtrs6SZibcqzJoHLR3d96n8=; h=From:Date:Subject:To:Cc; b=nnoasHzsDdLvEN2QpeRX1ph5kHse9vG8b5v0LLU9Pgf+Jij8GtrLXweeDr0HICtJ5 cMDJZHdbE0vlsdQRmKbergVjSarNn3ymSq7iG64hsibhPaY/usqwMhE77E+QlWhjrx RNuf0VS0RWAJMTybz8zNMcoHVOpGsCnUuwZPsEp209gn25zqw+91vdD2jMkvrS/WNM +3XQhojPT0nWmtDo0CHtqudif05HiW35HoIVSAUFNT9ih1q4RrOiJvMd+4jHY95tUG +XdDWuZMArvbjWOEpFzw0pVq1ibZX+3Ipx1mMljhIBadglr6hb0p+U1II4sQ85F7Fm 0aeNbqh5flXSw== From: Lorenzo Bianconi Date: Fri, 31 Jul 2026 17:47:38 +0200 Subject: [PATCH net-next] net: airoha: fix ARRAY_SIZE() division by zero on UP builds MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260731-airoha-spinlock-array-fix-v1-1-863a7e239a5f@kernel.org> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x2MQQqDQAwAvyI5N+CuUm2/UjzENdagZCUrxSL+3 cXjDMwckNiEE7yLA4x/kiRqBvcoIEykX0YZMoMv/bNsKockFifCtIouMcxIZvTHUXYcfPUam7Z 2oW8h96tx1vf7A8obKu8bdOd5ARE5m6x1AAAA X-Change-ID: 20260731-airoha-spinlock-array-fix-d239f7841cb8 To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Simon Horman , Alexander Lobakin Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, llvm@lists.linux.dev, Miguel Ojeda , kernel test robot , Lorenzo Bianconi X-Mailer: b4 0.14.3 X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org airoha_alloc_gdm_device() initializes the txq_lock[] array iterating over ARRAY_SIZE(dev->txq_lock). ARRAY_SIZE() expands to sizeof(dev->txq_lock) / sizeof((dev->txq_lock)[0]), but on UP builds (CONFIG_SMP unset, CONFIG_DEBUG_SPINLOCK unset) arch_spinlock_t is an empty struct, so sizeof(spinlock_t) is zero and the expression is a compile-time division by zero (undefined behavior), reported by clang as "division by zero is undefined [-Wdivision-by-zero]". Since the array is statically sized with AIROHA_NUM_NETDEV_TX_RINGS, use the named constant as loop bound instead of ARRAY_SIZE(). Fixes: 78a35725e533 ("net: airoha: defer GDM3/GDM4 WAN mode and GDM2 loopback to QoS offload") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202607311850.6p0ZUVq4-lkp@intel.com/ Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/airoha/airoha_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c index dba7c52c0896..64619e9a704d 100644 --- a/drivers/net/ethernet/airoha/airoha_eth.c +++ b/drivers/net/ethernet/airoha/airoha_eth.c @@ -3467,7 +3467,7 @@ static int airoha_alloc_gdm_device(struct airoha_eth *eth, netdev->dev.of_node = of_node_get(np); dev = netdev_priv(netdev); u64_stats_init(&dev->stats.syncp); - for (i = 0; i < ARRAY_SIZE(dev->txq_lock); i++) + for (i = 0; i < AIROHA_NUM_NETDEV_TX_RINGS; i++) spin_lock_init(&dev->txq_lock[i]); dev->port = port; dev->eth = eth; --- base-commit: 2fbade66245059c78daeaccfce13ecf499fffb51 change-id: 20260731-airoha-spinlock-array-fix-d239f7841cb8 Best regards, -- Lorenzo Bianconi