From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412636; b=Pn+rhsZ8d2yW/dQkVky8VOdgQTmI4rGs4DPYatvTUkVeh71fN3z8LZOED8aXS9b2rNxi BQCWQG47KsUWoHOAogpj9/6mIpTZKqm6b1w2CTxh+EJ22KQFkHLZInHmetjLq3meT1mVn iCHIEuxrqmd9GNnhCUjZWFqC6Uy0aFYk8WuiZOzRNG3aUCJR2EIDDyLm0+pYzAFvLmddg wJMp0DLkwRvL5CkDBTWFkZcNXXVwnSfbupKy1vU1eUIzPG9TSUrxIYRdMW+6Lp+X7QfeL 3iMSZQC9XFX3L8AIOKhzsUXOQHju/KEDc2dycy9fiCGOhfpqHfiI5M0IVRkEe8Ic9kg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412636; 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=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=y9HVS8cICxJOrL9qpDb6jAdQIPipyklHVZ7kEcC11sYXrFeiGFTokRsgbp6Y6lXtiIx9 iVXewdb0mSJBi7f4BlPRhlPvIjFjHuqrQoxlaJgTD/AdxwQfGhG8lVpiBpWDZGrQOREie JlJw8CHZ2Y9D1Pq3fSAHCk4O4Ewy1fnlqrGAz+3PdbuHu32vQIkpoT6uZvm4w4aL742hM k/KjbJY3zTOVR/s4ZLFsi/FiXYITYw/x4yDuQhkUQM65rbJoJY0wLVwdH2bpABJ8MsLHA chpT2a4XxFZTo5Uk23QbLGpURrpswAOoYFX7xZjI/4W96qOLZNqvUuW0rGr3Pka2wtg== 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=hY85agk3; arc=none smtp.remote-ip=209.85.160.69 Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) (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 1FC7C606A322 for ; Fri, 4 Dec 2026 19:30:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FC7C606A322 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=hY85agk3 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-46dade0d7cdso1018705fac.1 for ; Fri, 04 Dec 2026 11:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412635; x=1797017435; 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=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=hY85agk3C5YrJ46lwHah+oMmYW8KZmvmjuCRWS2m+1wcijXpmNrRqtI+wtkgou/jfF cxpbovr2w7gPgRbIacYfK0ki4QTFLrFPlYG1bzFe+LyY/+CHERmb9VZxXNpiQpqz3ung o6S8J0fU+1qUkDiZWQsifS0D4G5V2ejesL7Mz4ruHhOH9ZtVsawGpoMp3XJ2yvurq9tj DX33YH6JD6zoj7KFhZnanU5rEvfQVKTqs3VUzzeSPVKxRxApEL3M4Ob4MK0w8jjxtLa+ 0dKxLTgxPhifc501eaGmkPvsxl2NZWWGrUnsuRv32xFJI2+XsxTsntvocCFJmlZXeSp4 qQkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412635; x=1797017435; 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=puqzQgW7tX/RZxAVf+l7zu5bTZEqp1CKu/YwQed2Y/M=; b=GvVaH3w2UTI+Q9/1ONLg0REBTBI3mMQ5FyAOtr6ETt2Q6ffNrzHLLfnuRJZqsbKchF mVHa/7e2behJRP7WWSsf5mr8cgdHq78QWeEAn9V/FkgToA6Cv/hrV+LMog2LrD1JOQ/0 N2jIok0aPorwDsuYTu41PNKn+GbkzyLcu+F4yWMPUVpQrjg9P1sYDLRtLKbH6fZoCS/K 5LKvrFI4PaigIH7BVWnIUB1NEYRikTMd3ByUHpTjSEK0bbJPhz8n8m/ZnyeVO8VskBJm twnFTPOdDtgIk+p8rCeaYB7DDUrlXTSrRz94JjlY2BI6TnrH5+w5x9A53PKtnZ+fZb67 8W5w== X-Forwarded-Encrypted: i=1; AL+hErETceu3Cq+G5thp9ZfiXsyDb7VVnZvEmDR6zf3rb0gYPFk+8jRlNKqizXfbyN7PXZCjy+mMjuG07LM=@vger.kernel.org X-Gm-Message-State: APuU4Z88/GUC5jeQyjH7khZ5fUOF6mMIEhCPeVob1A5RfNftO6CIMrdP b9IxsAN4jw0cKnGE2Y/cjzXgrY1R1PCgApH4xgmcEDzU+QTK2G1ouOFgSmvkdqbfzRgTqNFBL1o cwXXL+mGN1t63fO57DsFSEFrCGw== X-Received: from iofl6-n1.prod.google.com ([2002:a05:6602:8386:10b0:9e8:9d0f:5a50]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1691:b0:6df:d73a:1267 with SMTP id 006d021491bc7-71bf2087f58mr2553913eaf.40.1796412634909; Fri, 04 Dec 2026 11:30:34 -0800 (PST) Date: Fri, 4 Dec 2026 11:30:34 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-7-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-7-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 07/11] clk: clps711x: 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:45PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but clps711x_clk_init_dt() > fills it before it sets num. The count is still zero with Clang 20 and > 21, where kzalloc_flex() does not set it, and on v6.6 to v6.19, which > use kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS reports > the accesses and CONFIG_UBSAN_TRAP makes the first one trap during boot. > > 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/clk-clps711x.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/clk-clps711x.c b/drivers/clk/clk-clps711x.c > index 27a57a9b3cb34..e2185b3daac99 100644 > --- a/drivers/clk/clk-clps711x.c > +++ b/drivers/clk/clk-clps711x.c > @@ -57,6 +57,7 @@ static void __init clps711x_clk_init_dt(struct device_node *np) > CLPS711X_CLK_MAX); > BUG_ON(!clps711x_clk); > > + clps711x_clk->clk_data.num = CLPS711X_CLK_MAX; > spin_lock_init(&clps711x_clk->lock); > > /* Read PLL multiplier value and sanity check */ > @@ -139,7 +140,6 @@ static void __init clps711x_clk_init_dt(struct device_node *np) > pr_err("clk %i: register failed with %ld\n", > tmp, PTR_ERR(clps711x_clk->clk_data.hws[tmp])); > > - clps711x_clk->clk_data.num = CLPS711X_CLK_MAX; > of_clk_add_hw_provider(np, of_clk_hw_onecell_get, > &clps711x_clk->clk_data); > } > > -- > 2.56.0 > Reviewed-by: Justin Stitt kjA Justin