From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F961606A33B for ; Fri, 4 Dec 2026 19:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=1yp3noP1; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SJr3q5Ix 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:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=1yp3noP1h0gVronY5oV5f11hlf tLl4Lq2q0wNpjC8csM1dQuAoE4WtfV8sROTdpktPw0ZzJZICyjILi71RaUpCav601r82n6rDw9mZ0 9KoGREOjv1kMB+S8Nae3qxKp+khq83lzvgpL9DXh9B6kIPls1LwJ36X8AssxCBM74jYi+plF3QnTA hAjbUjHbdRr6q6QVfuMbvD/5E1SW2xAVGuJjli76sJp07+J4u0wzGVXQikQlK18V7kge/sh3gWauN VblK6pv40YeJep5Po+6kZ7PpXjkwCfJM3gyihf6gOoS1C76h6WwRT1u6M2YeFHIx10nTQqlUUKxCN A8mpkW9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZ8C-00000001Jre-1oa4; Fri, 04 Dec 2026 19:39:45 +0000 Received: from mail-ot1-x345.google.com ([2607:f8b0:4864:20::345]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZ7h-00000001Jkr-1I4p for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 19:39:30 +0000 Received: by mail-ot1-x345.google.com with SMTP id 46e09a7af769-863475627f7so1528764a34.0 for ; Fri, 04 Dec 2026 11:39:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796413141; x=1797017941; darn=lists.infradead.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=SJr3q5IxKPwPQJWUno9CN8rG82ThxLkmkm3POSi2COfh1i0sN0P40N1lbIsKD/Nn9i FjgDl2ergA94O4NDJVpsdBU5nMZE033widO4AQCU7MzABXqtB6+svF6+ic8mNgQF9qYg Dhrat0CKklMdZ6bzJJVTenuwDrArZEDExzwtTBtbonFJEG197HpZEQr6qPKiPorlOFji djLyMTql0iLbyCVIwKBSvMOuFv6REflqibH9b6uQ1fA5mLGo6y319ER8ae10JhJtU6ZI m6ASxpN3odo52TRIzqcxgqWdckVKogv2B2gDDxhQvVBNH7/VFfxXO3jBh3bGLgyfaRTu zMqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796413141; x=1797017941; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=NCVwVvBWoM77V0QDgH25pWM6ueuPz7LoD3bH6i9tYQKVZ/nAqEOjJdX/gXAEbbv49J cJ73jijVioyhn7DBEzxaU8LHOS5h2x95Cs9t6PBgZOPwXYY5ZsHmfpo5+xW4US22kCLo RBAN3Ct4LVAbH5UtLvJj2o2ATwINWv4/4Fdx5KdMu3URVvyBarUJGPNPi3vHQOcIFjVJ WcoGEtZrY+vVHpyPmdtOUlrQTYtGfIeKrQdUEMjRvPJeBravtRZEVhZAk4SAE0EqWUs6 Dfj8FrgPz67lfGo+Bs9aQNYpKebvyPHqxLnmIJPllRGy3/4c4RyKypp+ybq2JmoetBVT FTfA== X-Forwarded-Encrypted: i=1; AL+hErFDYbrNhAj0J9Rs49YnvNXAq5qCixrNpy0CwM+iCl4Kov3H9t7pgU0TePphO/GExLCrpobgXqAJILzKbMLhJXCY@lists.infradead.org X-Gm-Message-State: APuU4Z9crd8WgoWVKZJb264OHvxoBA022HJTv/OfW8JaCk/7kj79+hFM n+LFS5UiB5TSZLqJOB9xyUYY8jCd0gv8jHLG3tDhEHd0ACnt32edNksBzvWPtM/tnL9z66gZpPZ Bk3DyCJ8y56H8keHAUyd1HRB25Q== X-Received: from iocrb20-n2.prod.google.com ([2002:a05:6602:a594:20b0:9cb:4cd1:ccdf]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:339b:10b0:71b:c1a8:c924 with SMTP id 006d021491bc7-71bf2072031mr2175134eaf.19.1796413140797; Fri, 04 Dec 2026 11:39:00 -0800 (PST) Date: Fri, 4 Dec 2026 11:39:00 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-10-2b0e4e8d9ea6@cressey.dev> X-Archived-By: Mime-Version: 1.0 References: <20261203-clk-onecell-count-order-v1-0-2b0e4e8d9ea6@cressey.dev> <20261203-clk-onecell-count-order-v1-10-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 10/11] clk: bm1880: Assign .num before accessing .hws From: Justin Stitt To: Ben Cressey Cc: Junhui Liu , Manivannan Sadhasivam , Nobuhiro Iwamatsu , Michal Simek , Stephen Boyd , Brian Masney , Jerome Brunet , Paul Walmsley , Samuel Holland , Emil Renner Berthing , Hal Feng , Nathan Chancellor , Kees Cook , Nick Desaulniers , Bill Wendling , "Gustavo A. R. Silva" , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, Harry Austen , Changhuang Liang , stable@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_113914_524207_845E43FA X-CRM114-Status: GOOD ( 19.47 ) X-Spam-Score: -9.5 (---------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-23.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi, On Thu, Dec 03, 2026 at 04:15:48PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but bm1880_clk_probe() fills > it before it sets num. The count is still zero with Clang 20 and 21, > where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which > use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS > reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap > during probe. > > Set num before the loop that fills hws[]. > > Found by an LLM-assisted check of __counted_by users. > > Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") > Cc: stable@vger.kernel.org > Signed-off-by: Ben Cressey > --- > drivers/clk/clk-bm1880.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/clk/clk-bm1880.c b/drivers/clk/clk-bm1880.c > index dc13d90bdd919..e2511991eeea2 100644 > --- a/drivers/clk/clk-bm1880.c > +++ b/drivers/clk/clk-bm1880.c > @@ -893,12 +893,11 @@ static int bm1880_clk_probe(struct platform_device *pdev) > > clk_data->pll_base = pll_base; > clk_data->sys_base = sys_base; > + clk_data->hw_data.num = num_clks; > > for (i = 0; i < num_clks; i++) > clk_data->hw_data.hws[i] = ERR_PTR(-ENOENT); > > - clk_data->hw_data.num = num_clks; > - > bm1880_clk_register_plls(bm1880_pll_clks, > ARRAY_SIZE(bm1880_pll_clks), > clk_data); > > -- > 2.56.0 > Reviewed-by: Justin Stitt Justin