From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412636; b=SaFafRSiH4Gmzxg8nGBYut6O927/aSkRnHGPPGftMxCOCWFTXPXbzBow4MTtG8eZVSs0 8KwHkWxBk8TNXV6062cYgdN/UihbGIxWXMBFsmxjiLKXMA1UhBg3FOrWkuW0/FQw+cT4D 8ZIHHS37Hpj5jA31jdchngVkgcLNHod/wLPaD5ctxIhZnJ3DnDfnuZTuwUfdu0LV/nPJn kmM4AUF8hT24KYpo/c5iQVIRYjohSHcOCZVsSfMNSlm3ta0dNHXNlMmhfWYwsM1FxAFD+ gmYjfLiy1fKZCQxWUH4VLgCa1m9GLg/JN+BiqStGXKvc7ltZchOXMVr5K01NnWhtiGA== 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=WWZugB+opJbdradypme0a1IT8pKmy/G7E9i9/GU8vOOmgi1wCmQ7NoyBwBiMbw3WVwp6 dg+hGy9YnVq6erOXYIIJ7m4CtXFBNGf6HuuFFSmQGtwov8fJX2bkaaxQDc9NU8mVzsNf9 bwGZrdx9yGE1kHAiUKss87CkuJposJfW8F+jdJvW1oMYvJolMdtua856Pm8vSHuC6LRWt nFeX4SAGmvS9M/D9/nfe5uuB6sovEJY+ERSEkBLnMrFbVgmhwilTDM/x8YChJIesMc3N3 6EHC2mkh2EUeH4Z0xrXg+Mm/4Pz5+LQqv+EZLfHsN4zW3SaOXjjBJu80AAyBUxQ35Mw== 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.70 Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.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 26700606A32D for ; Fri, 4 Dec 2026 19:30:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26700606A32D 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-f70.google.com with SMTP id 586e51a60fabf-46dade0d7cdso1018708fac.1 for ; Fri, 04 Dec 2026 11:30:36 -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=mZBfPB5jcfC7okMVfjogXuOMnrsUQUawJtPs1s4IWvSocGEyHkcmbNkKHcwomfHUBR saLkWGc6tGgTMQ9v2hDNGZawtWGBhgyV5uMJuCwUhwIx5utE/PreKtQwMomLss5EpAa6 AimwInPADPOnVDnO1dwX+BEGS7p9wrVVlrwYSCYEGnZ1HXdgAofiDbuTe9LYpfBWt9as XH56BfFaxFal6YN1EIVVSGmdsFvZj22DeaPHYNusH9S1gtZezmOqiNEGvJA6N5L3ndVl yoeTg3pzrKAwlSfzPsJD4lYVqXLPvOIrYZp6MXLBt7E7bZ5A0qbespCu+B5zywlKCWDv bpRw== X-Forwarded-Encrypted: i=1; AL+hErFUBzmwfOLiZWb+DNvQVEKHad3cto2adhK/s82DzOvLU97a52H8fLOAuqFbPMu8YFwjOtnx38Y=@vger.kernel.org X-Gm-Message-State: APuU4Z98nPoR4giyZSrRgTYMiyAcSu0+R1RK8ZJVFPC7qsce8vlEa3LS xuGnv8uFM83sF2qmZN5u/KNj3NZhgVEELf61EiZDWNMLfr+Qb047f8lTRMICFBCdnXyS3Ah0uyh l2Dd+i30Ao1LQjVLBw5acbOACNw== 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: stable@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