From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412098; b=oBHgOnQb9aOiKxE1MNtv/bqLbQNnmqFzID6M6meK5/8QEkykXyNVRAtPGEhXfC1kuree VBYHGF8/p2eieVnw10HzSV5DCXzvP7HtWDHYNT/Uhuh+GE7Y5nRr+Ht3J0BCCknQ1NxL/ tEuZxSfRk0IZY5Daee69GAvansLpIwmAF9Y+GfWMn25FirEBCvGYrgv3552a7oNq8V2NF 1UrF89go8QNFHEHZpkJluhfrbOZPBk/iHqmNMivKIpoUtqJwKev0FJwSsiLTm1HOxSMHg Xba8hTaIwpHl0anYK1CNaAhV3DtzSpN+N0YQ63/ENfUfVc/Dxm5vDH7nIhLL+YsVS2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412098; 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=Je9oU/uw4pGqyoOhCZw2Ijq0xv0z6GNppcJuU0DrjNo=; b=cvJclsHnh8qg7HujuMCvjMiM8U5ld+Z86HVTOQQmz7LshqrdNiVrm5EJ9Fj6SG+p8Yiq k6ibCi5Jt6yr5x9pfLUERK8alNj5d3Ku0e+ZOMD1gt4QbigPRYMtSeVFypj1VFQIu7eiA rcaZEhuGE/kyGrLHMBxDjauIp/Rks5fE2lhC+WCto39sQsF+sIDlNVRdNGTKjd/ARDj7R yteQFqVq42y7ToT3m8f/ymnoXiasLb6A8T22X5ql8p45vMHoCvgCrKVdpSm3c0nOxajfC gnC4T2NW68XLmUrZxKp0GhsTkcQ+PuT0/oFUi+uE/C/XHMzcabD3g50LF5scxQ7UkWQ== 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="EUU/gMsn"; arc=none smtp.remote-ip=209.85.161.69 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.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 589D1606A330 for ; Fri, 4 Dec 2026 19:21:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 589D1606A330 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=EUU/gMsn Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-703a37d970eso1564573eaf.1 for ; Fri, 04 Dec 2026 11:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412096; x=1797016896; 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=Je9oU/uw4pGqyoOhCZw2Ijq0xv0z6GNppcJuU0DrjNo=; b=EUU/gMsnD1hIsCfPgyt4jXyZgKhbTP/BrGrdilyQfZOe2J42Bow3aGAr+H/6ODSTCm 1ESocz5cuINxdO5X5Dsuw02eGBIbsvMsnRLOgR1nryaoCtMULcn2X/ZPaAapAu+5EQ7+ FW6vaeK9a0yoZdenNMj2dsuizVdPFzuoWN6EoFFUsHFgjf1n2ZrVdZeZ5TDQpaa/frqN gRT4BBbcUtLkeuO2RzCRWiENE6b3Z+4R/yVUYfVZ4HtTapLSXQrweMqWA8DDGsqsVYPY 6q9mEMrLLfZ69wigUMYVMmP6X12KvumcNn+cBeheBXQvKKjY3FXWOzK+BPx6jUvIxdvF Ipvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412096; x=1797016896; 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=Je9oU/uw4pGqyoOhCZw2Ijq0xv0z6GNppcJuU0DrjNo=; b=n5HxNqv0maLXfSzvgZzZoQ65qBlerTcUgWsTNVqpzUcicxstCvMhA/fTUMPMtKqJQV rYpdaMWQZsnMwQvAgGtO3/O6/k1bfPozH9A6fPk5w0+4YbF2FSE5XGwQxK+i8GIx8xfM 84nWWcD4CC4dsKEncyW6EyIFiEImqn0paxDezWHQNUvaVOC/MtRVsjEErTTfkAZyi262 Mn+E55wHMylpIlgZe+VxNrR4zQG/U01dFmpGYkNIuobKVxBqafNQhT/LEwqU6kADY9Gw gfXUZezUcvdSo0JDdJpp04CZIvUKs0R1hcfuWrSXEujpojzS+q+f9QFRSLTNNQ3M71sj OJCQ== X-Forwarded-Encrypted: i=1; AL+hErEPyFzXEJfQ5X+qONGnUmSZzEHxbVrRdziWZZVsVf21h2YCLER2g30MrYvKekwsDWoweN5LhvWU9fI=@vger.kernel.org X-Gm-Message-State: APuU4Z9dxm1zU8z/k/Qm2LioMXJL9yzTxN86CGk6+YvBUtv1N73Guhhn lQUbRdj+xFJtOE0gUhgAzag+ea0MJItYdUoyxnVRtX3MKlnwjSwp92HoHEmHkihP06E74+PH5zm v+oRGdN/kS8vmC7THW6hn44vIEw== X-Received: from ioi21-n2.prod.google.com ([2002:a05:6602:c655:20b0:9ea:45c1:e7a2]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:a288:20b0:71b:7bb4:bb70 with SMTP id 006d021491bc7-71bf21b04b3mr1949610eaf.68.1796412095992; Fri, 04 Dec 2026 11:21:35 -0800 (PST) Date: Fri, 4 Dec 2026 11:21:35 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-2-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-2-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 02/11] clk: lmk04832: 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:40PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but > lmk04832_register_clkout() fills it before lmk04832_probe() 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/clk-lmk04832.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c > index e6e771e8eb145..ad66cf097b9ba 100644 > --- a/drivers/clk/clk-lmk04832.c > +++ b/drivers/clk/clk-lmk04832.c > @@ -1435,6 +1435,8 @@ static int lmk04832_probe(struct spi_device *spi) > return ret; > } > > + lmk->clk_data->num = info->num_channels; > + > device_property_read_u32(lmk->dev, "ti,vco-hz", &lmk->vco_rate); > > lmk->sysref_ddly = 8; > @@ -1530,7 +1532,6 @@ static int lmk04832_probe(struct spi_device *spi) > } > } > > - lmk->clk_data->num = info->num_channels; > ret = devm_of_clk_add_hw_provider(lmk->dev, of_clk_hw_onecell_get, > lmk->clk_data); > if (ret) { > > -- > 2.56.0 > Reviewed-by: Justin Stitt Justin