From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412264; b=RY4vLm4GuR54toEN3k0kmg2ksZscmAk1v+Oa+lHhuvLVxX6fYkcdEJlOsG0aNUUnbL2h JKuLC1poOVh+uAfuFuhesqQPJcfFdhI+CQXbHi2n/NCsILoFtosbZMj+fBt3DXFMrn08p HPFX4VgNyLWD9GazqP6PvqFD3+5rkXr35u8EOBeInWfNa3OWvn6R8OpjEiluk1+ZuC2o+ yC3TMmkxaefMvQCag2Vnxf2m0OB5sPxfaQIRIOA8+Cs94udCvMH4IB3yDfn4YiBxd8zBa v4+4jO9EMSDwUifdDN3DPSZgRmfsnPCwrjEx/fcFTFiOn9h3B86nZT6BT8VNiRg35Tg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412264; 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=p1Zlo06uylO24ibcDs+ylc+YPQkL+V0Mpwu5t7O/fVo=; b=CKjHEzoMYWI4BBCYWGVazXFN8TOsCGl2LBEBFqTvc5uNxVDO9MJTYAuv9eZtFt2RPOaR 5HtzB/0eTahZk3wAlnXjEEJo6T7/OO18Nf9tASkeXnO0v83IuO1azxhdF15/03R4YYrgh ftqzcMWHmSK/2EMo6UH6yLl48Z5zpFXKIL1lBBqi4q8Vx2SQ4HIKthpo/LtQQJJ/742xc NYfmBb7Nx2lKpNWbX4awGsk4odb6Ep1j94rTk/hXNcfpi+O4uBGxVKEznMHRVOxiGiHBA I/+IhbNxHsiBHmwSJb+HOdBrdM244U/pEXHZcaOQ7fmlLN86JoxyKakUXkDn0leZ2DA== 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=WRLkd4Gf; arc=none smtp.remote-ip=209.85.210.71 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (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 ED044606A32F for ; Fri, 4 Dec 2026 19:24:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ED044606A32F 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=WRLkd4Gf Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-86320da67fdso1804100a34.1 for ; Fri, 04 Dec 2026 11:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412263; x=1797017063; 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=p1Zlo06uylO24ibcDs+ylc+YPQkL+V0Mpwu5t7O/fVo=; b=WRLkd4GfcQvSxT+lM4C4NA2J01ZspytpdgrOTFNQFEjYmEHnnWHHFkBxAavMMv0jWA gaoDFj+MZIzEvfIxCIjQDmtcxerqVfwaUEp5Yg+st1Siy5iNp3JUp+YqkO5/Vey4pfJb 9mSzqF+7fdHHzjTsAkgQekB3i5fKgYwOWOkRsaqLZGJ9WssMiexGUdMQ7L9rj3UtYdV5 GleOk5fZuroU/U7OHwp1Ia66BbRf60VmlN5ZHBvlWh3WSmnp3jpoDK4wii3lGeYLFjSD dcBzvrRQ/1eG0Mm2aR8x2xbi7CoWRRueDwZnZeXh2ebXGL9C9rmhU00ObgmjCCUAunsN nnWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412263; x=1797017063; 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=p1Zlo06uylO24ibcDs+ylc+YPQkL+V0Mpwu5t7O/fVo=; b=yIwZuwflgw9XmZGKT6c7BcLPmUQziXidVu7UfOQpoFH+/jkZYBZJ3tYKcxkjmeD4Xc cMJqsJizWTA9cNrrLKdLOZJBV1KYA+mNnFeXuZ5MdEENsSU4RvuVscbHEpmOgZSNhUpU 3G/QAYc/Yy2omJ3TVsq9KqdJD7t4Gz2TKKhGgQzLO0OCqAM4A0IT+zpZcQKJaMiQjNxl B1Un4NNu6QK3NDvLOInfyvoHV6RpDzV69ptNW0qJmabhkNB6h17u/S51rPiVjdnur6g9 fW9BUgLmMIWTQAYEYDnnJoRWNtDFjIW7+6HMA1JpFPzP3pcaxTlcIRNecud4aH/NeidC /syg== X-Forwarded-Encrypted: i=1; AL+hErEfupBWvzGWdkmGokhAvMqjS8wrZBgSQ85qlknsuRI5N1aCg3MMhvWgRASCaQ9Mjr7dKXTiM8BTo94=@vger.kernel.org X-Gm-Message-State: APuU4Z/Q8jTTZ1SreUWCSKFEj9vgcoYwqIwuYR6/EkDtHEwhXW6bteSD kRtnUyx+3PESuo1TOm4ZvTYjd4Oh0kiuDifuVAUDkOI9XaCaTTXy24zwyDXloK+qskECByJL3H8 wPlTRb4vHOgrCJIXBxcGlxNtWyg== X-Received: from iocou4-n2.prod.google.com ([2002:a05:6602:c304:20b0:9d3:b408:7991]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1c90:b0:71a:e0bd:ad03 with SMTP id 006d021491bc7-71bf1ad6f59mr2959818eaf.9.1796412262645; Fri, 04 Dec 2026 11:24:22 -0800 (PST) Date: Fri, 4 Dec 2026 11:24:22 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-3-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-3-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 03/11] clk: mmp: audio: 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:41PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but register_clocks() 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/mmp/clk-audio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/mmp/clk-audio.c b/drivers/clk/mmp/clk-audio.c > index 19233684fbf9b..6b74aaed64b41 100644 > --- a/drivers/clk/mmp/clk-audio.c > +++ b/drivers/clk/mmp/clk-audio.c > @@ -340,7 +340,6 @@ static int register_clocks(struct mmp2_audio_clk *priv, struct device *dev) > priv->clk_data.hws[MMP2_CLK_AUDIO_SYSCLK] = &priv->sysclk_gate.hw; > priv->clk_data.hws[MMP2_CLK_AUDIO_SSPA0] = &priv->sspa0_gate.hw; > priv->clk_data.hws[MMP2_CLK_AUDIO_SSPA1] = &priv->sspa1_gate.hw; > - priv->clk_data.num = CLK_AUDIO_NR_CLKS; > > return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, > &priv->clk_data); > @@ -356,6 +355,7 @@ static int mmp2_audio_clk_probe(struct platform_device *pdev) > if (!priv) > return -ENOMEM; > > + priv->clk_data.num = CLK_AUDIO_NR_CLKS; > spin_lock_init(&priv->lock); > platform_set_drvdata(pdev, priv); > > > -- > 2.56.0 > Reviewed-by: Justin Stitt Justin