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=1796412264; b=Uk+yjsWIE2ZkQaqvUCYBN0RHrdZVv2JuHoRSINvbHpC/WeTcF0VH92OU3DiUvxhStWll zojak0GdBGZrKieYxZLJQLC3aOOpGmKV/s8egix/peeME3zMhzSIvcfKk9L81rVxoZ1Je JA8TUGXrWVlob6qaksZP6wWN4I2u/Vb+8zNjX764CXmO0/d4AlyTCwFrTLiQTg/i5/0n5 CofhGA6W/dx71g8PcEiqduVD41dBXRhf7NdlfYEznDjRSYPgfld2y7+jRDDLY6SJSeG8r rp/I1auBvz85CRmlbNJ3klBHACmAJMnYe3Ffs1zYG3IkLLpoBIZjdpKHOlgj/r34wpA== 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=s/gqSdjmxK45fK+AcB+3YzgswHB9DTcSNszVpSy1ryqLffvn15mFFEOMolyyX+UGKmRb 0pyu65kdQuJY77QBso5iooLTztwe5q9C2jfe638wYF/pXg3pPp5HluyYUlCCnbeIHuBIz dVIIk85kL5gIgngmwvnnEBiJayQZ0cE9cDEH7luglEotCW+ViHhifEpLrHVy90kF9KI5q g6apQc1c02hQQ6HDbZHHIeHC7GaUvtQiarJHw3IYyGbUFoQJyCDA96/yC5/kgVLb3yCsq 9vLQU1u8aPliLREDzUNpExmnfGq5BtReTdWZFBperVh8s4+l91ue2nCDXDBM63PKJpw== 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.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 06E61606A332 for ; Fri, 4 Dec 2026 19:24:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 06E61606A332 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-f72.google.com with SMTP id 46e09a7af769-8520e83f715so1631882a34.2 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=oOvOARrIiVx1axrxZVDoR5GNxU+c322WJdwC1V3QL5HGNbSv0iGejW9ExvdcKv5VBv WF9RuC+XmKuvUMLbivArRJvrG77YlNCKjtFSKn50CKjj0bCYl2sbYKo6ARAHSIkTymaI a4CTwohWr5ggNVSo9znh3l3D600MFuVvDVludLQEKDT27/KTznDBoFB92Mk81g2Qf7HY 6EzMJAojsnyK1ZyMMShmHVd6yngNoEXxLzYAYm9a3EinqUUD4bXCuwL+RyZ0CSOsOlRT i1UBmqxLZDrZE6mRDJQvHEkrsQfupFd4gEoS1kK5IpWZitQTMIroCa7J9xpuM9vo6Uvp 41EQ== X-Forwarded-Encrypted: i=1; AL+hErEDzr/2/rY1kB9d3OZkTd+s/lgRJ9cuhnFg6A4nQRMru5B3tiiBqpkXE4CeZOS2zBXNXEs3YJY7iDVw9YDibII=@vger.kernel.org X-Gm-Message-State: APuU4Z8Gi2iJenkqF4t/dSzqPzdU2JVT5686cIpuHyQMaSMVOqvSxJDV n7sYiEUrLvldFWsrbyL/gJ0A0gjgVZOXvrT+lPo4ZF3GFINs3HQIzaAp0qhRBcDdSbRfaVEY198 ayCkgExgk6u+ykfoP5tqPXAR6ow== 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-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-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