From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412264; b=2fyOBB0gqMnUTlpNKwQqgfdEStJZstqP3ssrIVnpsbNRS24oCkjqEl17KOiUxGY4vVQJ vbBRHA5U9CqNhu642/QbPHKo2Ff2tFg5SAX+1jiWaSO7ODPFv8TC+nzZdqvxY2bsFyB9g 7g3093a3+c+RL6uzdJWOWslEG98LG3mUwG73UGttKQvmgWkJ2mUCrVRPgz1h+lVajZFz0 Kgpfgb3f/TEs5nEyjgYrxGYmf30r/Cj8ovxP0n6fYSFJEGafj8HJIDSjK2FaZgU575Y0t KfLZ+juyejHWvz0vhUxZUqKPlJAYYG6bViVFW6nFxlOUlkqs1mkRScncE07qiiSyc1w== 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=ig2YGsy6lB5gT3e0ycZJrNyzg5jlxj6OYjwZiSoRkSMtgWFohGt6U+8Y2lq/X55jDWMp NlvNuFqxFhgV78tdKkow61iEZLFmNCFUa03FmfpqSnIUtMiqoe8mi1np+B/PpjE24Z2k8 /VdAc+WA2AI2vhOoK2aiAi7G+fSCgIIEhKoo6r+hIO9XxFHdx/1krYiI3E4zM0UQXAOmu 4IR269mP3QJljPkgysJIB9QgS4DLN17L6HFIsQjIXIrssLO08v6hWO83hAQqvb42W+sHj DEyTdbQI6kOsdjffT73mMKp+UBxxkwXMSofvfBnpdOeUmFeMbMjhim+Cl6mwJLM8UbA== 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.70 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.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 1E80C606A333 for ; Fri, 4 Dec 2026 19:24:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1E80C606A333 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-f70.google.com with SMTP id 46e09a7af769-8520e83f715so1631886a34.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=2OB0OHrarw6aaJuinK1TfVhdHH01GQaxQvNWM8Zd6L2MYEtd+WHMs31A7WaEiIqnA8 FU4lN1MpMlr/giXmjnVjAq5ZnmokyK8FKz+BjLHMoUD88Ukk4Ui997xRWhjs8kRYdHFk 9YlhmGmkF3lJkN3g3rRvzZyGZCAQg4c52Di01/PjsRpZy5S03G70sY8w8arthf31BESO i4Me+qF287T7VX4lCovIimdaJPErAYJ14OOiR3IekjDb3EfPYbD202Ce6b3Pbc2J9nvd S400BI4hYARbRSmcnjoNLVXaj4OcZW7yz86WxYMrKMA8qu+YVwuMehiU4j90rrMaiq2p L3qQ== X-Forwarded-Encrypted: i=1; AL+hErFhcoojPx3sHZdnsHpnsa5YC1XDQzSpe6pOibyLoql+Z6p7ViCP0jEEVIIAgZwGMibmDzGn2Nc=@vger.kernel.org X-Gm-Message-State: APuU4Z/wC5kdO+/xVKxYSaB6BUTJC3aQYX1arknS6Ds4VMh5+AgwLn4U yE2vfEAcE8AI+zlUM1pnquLqIdLP3u24DhFHzgzU2M2Jv2FWSITIsPQ2koSoKMNZd3/hUgsIKpi /6+ETQ9XHUiTVOCIyjmODa5AdPw== 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: 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-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