From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412553; b=F63kcOQZsfhIr9wkYUPzrMzkv8CK6v5QyXYLaIoxiNNQs6xuAwQN1R2NgHn74cWPx4vZ 01kTGvEFzEWK5q/HcC9yljz3HRWzQ/g4YdQik6Fh65qcSzyWKV8sFaL5zRpfBAX/PYVAo fY1aEd6P3ezLWb5vntQh/hr4dG1lbusT/rUpFNa4YvgyJav8Sh7sN+1QRC/Pjbl5ZSHRu 9KOZCIjPOMgjtnk27JmgHtnkLxCHD0s0r0huDjePpd6Ky8bER0sXSD4JljI9n1MCPAueG bGWW6htFDat4cJtfkzzp+qvyYeOob6IChuwbcuEOy93JU+6P2qpd5cQvOMcGFMuor4A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412553; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=LmpeFgpIZbYDaD70tVCHcLBrT9pannrGnSUvUubbAzWCurF3xY+CX7brnCDOMPtay5sU RyGxfl4NF6YDekqgnR8RdlpHm2UXlQkaweJL9ro4PknGw3VoO87dEUcSTEceg3+/GIL0K c7GB5Ta4DHUDSDQp1Gw0SSAnz8UzsGb0ZvZhILWkJIu7yUOmCTxPv7MWBz0FY5KmZ0st7 SvRyYmeTyhDo6GV8fdNiLJQbOL39S+VH1Oppi5SLrY9ba5ALl5/GEcaAFWwJokZ+YAq3a qI1JGNTDYvVBpybDfsWdWyGZUnhep6G0mh591ntI/92iW6UZyNRM7v7VwBgrEWrJCCA== 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=hzfTFEb4; arc=none smtp.remote-ip=209.85.167.199 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (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 0B30F606A32C for ; Fri, 4 Dec 2026 19:29:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0B30F606A32C 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=hzfTFEb4 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-4ab4f652f9bso779870b6e.0 for ; Fri, 04 Dec 2026 11:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412551; x=1797017351; darn=vger.kernel.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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=hzfTFEb4vbPxygHmihKGGAB5wZGdQVJMELwXndeNdeRLBVndC+gzFeHe+LP7i4/iKl Cx6L9Ghz2aEnjT+3Fe630wL/lQOxx6b1h8LxkvVu7YpFCGZYD4oeQ+LwfDhyfEQqPG+5 Q3ImFJASc72XoAx4p1/9Y1dI96xoY+3i6UzUNoA7I4pqCIRx379RgQxKiskRYzZXDhbm zI5bE5mPoJh7BU8AwBb0Br1+yE8ADaY/FYN68kz/Zg2KAd9AwjTdJhZfm+NBZ1JiS6A1 KxO1etZY6u8kXIyp8HTKa9CBfuOJ6JcMmjYIXk72CYzJQ0yRnafTWSQ/nP0CNRAnSlib UegA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412551; x=1797017351; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=iQOYWV8qImTHmr/kbMpwshR6P/3eUQzbFE8DXTTcPvttuiIhSNyH+EAcci/KMhQ18N SODE9D/CBiqT0/84GXev/6kA0bamI5DAr18ybNPP1AMLu1HC8MC1OpCTkqyvWyeuCd1H Lsez4AHtokTM11FjwwwHkvMPBnVeWd5WucUPaUx1gdojBwKWHDWpDgxFNRksgECDxiU4 rdX1L8pbGLxkGW5fC3MNPZ9IgrSrbUIO2queQ6Vpot2abf91VCakQirHd7dsCVn+op/H HjJta/uKu1BV+3ASSGZoFyPZQcscKvL3eTwYoHtIgiSmH2oCasPcdfC/aG0qLyW6MLXl nf6g== X-Forwarded-Encrypted: i=1; AL+hErFmwxUE7cqP21qrKz4kzZWRcH2us3MS/SIr3lvzkJqzrWJfOMni9GS4dECFbXcL7mtLsQz5CIKgzr4=@vger.kernel.org X-Gm-Message-State: APuU4Z/9T4DGF8qYcNwwzHXfd+M1PRldGmRFSrjumc4BARJs/t/YZpkA eSt0RAV+0790L0ManG2z2pRAr/Qn65DBnhAllpDLl8fO2Z0r4BXVRH8GE0bHm77qrWjYab70Zvt XBpuBpVZJtNQOJ5Qp8ewiomv4bA== X-Received: from jabge8.prod.google.com ([2002:a05:6638:6808:b0:621:d390:8d01]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1692:b0:71b:7bd3:8a77 with SMTP id 006d021491bc7-71bf1ad52aemr2665572eaf.6.1796412550766; Fri, 04 Dec 2026 11:29:10 -0800 (PST) Date: Fri, 4 Dec 2026 11:29:10 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-5-2b0e4e8d9ea6@cressey.dev> X-Mailing-List: linux-clk@vger.kernel.org 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-5-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 05/11] clk: visconti: 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:43PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but visconti_init_clk() 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 right after the allocation. > > 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/visconti/clkc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/visconti/clkc.c b/drivers/clk/visconti/clkc.c > index a75163b69751e..f8bb93d7027bc 100644 > --- a/drivers/clk/visconti/clkc.c > +++ b/drivers/clk/visconti/clkc.c > @@ -195,9 +195,9 @@ struct visconti_clk_provider *visconti_init_clk(struct device *dev, > if (!ctx) > return ERR_PTR(-ENOMEM); > > + ctx->clk_data.num = nr_clks; > for (i = 0; i < nr_clks; ++i) > ctx->clk_data.hws[i] = ERR_PTR(-ENOENT); > - ctx->clk_data.num = nr_clks; > > ctx->dev = dev; > ctx->regmap = regmap; > > -- > 2.56.0 > Reviewed-by: Justin Stitt Justin