From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796413143; b=RP2MBbPTq1rc7TcQxCt79AD4UyjQwxgrk6xqc4E6jLs6TlotLZjKwo9TnQc1I1uDJRxT G9nINDe/QV90jZwEraj7dIWTJGGeoNHyYWkXPtgqHGW8zFVyP+tM+DEr7O0kevBusL8UO 4pDDyOvhU0GAr1qcKpxR84P4MpnMYHKyCqHkMFAKg7XNHfR50QMf7oT+4FAtiVoRTk+hP RWn3qrlYLcw+orTG+Db0yz55jhPnph1uUY0KnOTxBqj1KjhKw2XFl3ec/+Ltqw8NCMINb ikgrVRvQvOcrJZEpbFtU/jSV3bnKa3mrn8UpseT+BFh+/WWN7wHIs7/Ns2OSGbi2i9g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796413143; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=ILFarcpFu11WMtNmReWj70EtNgtn1MALk1MV3HYidPqRT3aImQtHhiwX4TAOnRgdiIWL 7HAnl8BMhtzLDZqlBnyx+AAIXWNeM0bAjWy/wEfWc/0z/JtRaemxTq+j8pQqa9Mn2LgHG yhiTRVuHTMydwP9XptoN1+GsmRmB6TEsrP7v14tUTzv2oI1mB5W0pgq191rzDCPvoLEzn G9XWbKRM65C25GLjtqPKbtizuuQDW5BPxyoqy8gIgReGbcx06+fgj1oZMdjD2yfYJErI6 zIyTR8ePhk/1iTTG5wVsY3xHfrxTdFMq/KcqWTFmaEfKFKDG6pHVIxh0Xzsh/lNJShQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=jJyxpjgS; arc=none smtp.remote-ip=209.85.210.70 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E273C606A322 for ; Fri, 4 Dec 2026 19:39:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E273C606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=jJyxpjgS Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-8615bdcc5cfso1796107a34.3 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.linux.dev; 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=jJyxpjgS7LldeAQfbRidFAWvbx+U0tbmQQS1XiBvq6/CsUcPjib5Chxezonuev5jWh JaKWvWdn4Hx1eFtkI0irR8YamXy9vAOBdSyWpSxAMvnMjW6F8n0w71Y99isXu5k9tuXx Hcm+wusKZzoZps1AYC7DpGU5HuHJzWzzVfpOwbN5I8F9gnEfn87OGNIe3w4WW2sDLBso garnZVOdsgbm3YVedje68taCT+pqsN/aR6jb4xZRhrRH3ta8n12p2lnLfWYx1ugOlCCM H3WZDCe25qIZpJiF3YI4vH6M5Z8abyg2LnorJhprp4usRaso2sbm9A/KGSkWH6rp9FLO jUYQ== 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=fSNbdOvFwuWh82/FHA2GOUN5SeFPSG1IUEyV9hPkFJoRFRow/3IAPhpv3ZVVqc9+vM KmHkBG+Ve6NTQ2B4L2NwDCnrcDlARnDQIxGcM3JfiGPkZSd16WdwYcvRc/I0S550sILj NBZOewauq5mPFsNnt2wd1SAz71hWi6AmupgnDn0B3zd6EbQ6g9knpBYrdOC8R8+WKrvT pFNYMtviPaVt9DEwSGDjZdFDLTMq/zwAzADWbE1INYeVAd9JLn8egvKTESLO+m98YxFl +qDVV4XK5uDEX9Z3UJGZgO74m0DLpd9BaN5zSwXvf/EWOUnd4LurUJkII+n7ESqk6hw0 YCog== X-Forwarded-Encrypted: i=1; AL+hErGYbl8lAnUwfX9Ur1FyZ62K3eWLKcF+5eaODqMg52Gn/Yh7jeNTk4DymYLDqKWIbkKJUVTm@lists.linux.dev X-Gm-Message-State: APuU4Z9/gh5H4R3MgaD23CKTNLQGS0vQrkreQg3ZMRK4fm7CiQ273u/M qdI+yl2/Ta+SykPaiT9gGuoTa4uRc6GahQuDrJFY44BiC/rfGUV6ajMYAvBHs9PZwcIUcNT/BQ/ 8N/6LLUPDUpposMVjTQNnkOcZaA== 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-Mailing-List: llvm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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" 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