From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412097; b=IbImnAuYAWAq3N5/pSkie8w1m+kXYYaVIic8erCX3quO3Eg+HlvO1w0xqo+3c+0494NL Xj000wNxy7msvTWlvJo0yyHHrV4Q6JMGatAQNy0iRfmrBFqC616nOQE+MPlm7S7LpuP+1 64U7o66mjvsAoMmLWJx/TitJ9OdMWyBpThfdCSpsrRI4KxP73DELYgTzXoBSjw+GaRnwu EsyePF0AENZ2Hzm0NlNE1UFlsoMH4MYUSKf2TJtwy/eo3kXRItmwjHLBJXZs9uCo1Rb4g n4vhVDtKlqVyt01Hl0kTrmjSyvrCNCgkGD8cKyYSCm/ygWLc+A6Gs5GmlR/iogxyCuA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412097; 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=S1jSORzaxpjKXQEmhid5n/1jGIrVSuQVwDvfpGIbyjO6FO9i81XBHSOMPspZr3qvsoZy T5a+I2q6IxJVcn0AHifqpS27vvIzfyu84ccaCGnakQajtqFaltJXPQqE/dvsK0zFc/7uU Qjn0jnq4hh5Zx/FcjeoO+YP9Jrk7WPDQwUlrQ3hbeX8k5rfo6ckJttlmyiT3zs71yCp1/ /gd7Psb9iiR4ijVtvsIuLPdiv1m73KWHfMS/Nn84uxaPmZanc2OhsOyH4113JtZdqh3vr I7zn4k6qE3UlMRedGn/VRzu2PLUv9QcYlZ3HKLSY6enu01qkkoKcPcsB2ZlEXXNuNqQ== 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.210.72 Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (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 42C13606A322 for ; Fri, 4 Dec 2026 19:21:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 42C13606A322 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-ot1-f72.google.com with SMTP id 46e09a7af769-86285932977so1595274a34.0 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=0cntjBB05gifu1i5hzoHKSFwhvUbhcmtoXiwFvSpdp6zVYgpqxE62OpYXDYZU7xcoo rFrAnEGHEG99ex7X04IhTsWh1h/unP6/O2HQy6z4TyuhljXyMhJl0iBhx0fPR3XMRPg+ IggzpXq1XHib9uJIpWwIJj70MVL8+EghQmq0ha5VIepAmdxhgM7JyiVev601+rybX1z8 lOWqU4CWoHbjtFON82QnQUlopSs3HNQwGHlIDE626rtT8XZtOr3/zM3rffBXXROQx55/ 4uQVX5TNEt91RCcQ55hf0PGPR4vyG798oYhOx7xLdi9InU/X1mVjsxc0GTh5LvgXk4Rg wTDg== X-Forwarded-Encrypted: i=1; AL+hErEPrgSA71D8Yzm+9atWBx/jQc78rlua23WGcVnMEyl2AZeeEPHxmOxz8YU/4e6boCBf3BVikVoJKR4BA9UsizA=@vger.kernel.org X-Gm-Message-State: APuU4Z9xuzrQCt2hBfGSWDAdv+FtnWeSldYABWlkW3QQUa8Qgodg0a8Q yMM5J9iNqZFWLTgp+BO9jD6v9yPd5K+4nARlCxKGaUWgmjlTeeAI2s9iPjVTfzJCOBI5WCxCxa1 K9/S/wqHLVbl6t5jiuohMesACBw== 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-hardening@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