From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412264; b=rMkYvbYAx4fAsWuVwcnf6xbHIORcwYb5bdzIYHJc8c7QOTbLTAeRGnPcqUdqmpqnCavk k9oQMNWee7NJxLxL1tpfNojCTbLRyza5KxPJFKlk/4bgL4L21GXZxE2kaxRoMjTknwN5d sbdwsWJTp6X8g8Q08NsWk050ub0n3pKrLFMbHvUm327jC5mpwm9PtP6w8axTgzSLFtmtE 7Bdoefq3t5LiPdqsb0PCCVTq+adUn0mX5NqAnpSPEVcCu9sM9pmT9UzGRWJ545ftM2UeJ +RQA4raI7fbDUgdR27H9kkB9pkFg07uytWDTbE2ZJ8fRCfGPtYR++ox9Av3J6PUiagw== 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=XPTJ5ARKvulhJlrZVFk6iG6wd7BByEa3KAzQCE3nP8sn1tzUzvm2b1Nl9YH0JrgozKQs DhkMirh4P/kQosRl84NANfKnBfunIuIGt4KVx19qAF7I1wPNCMZ8lDKdb42WlwqH7Vo74 u2hyx/DJ2UujhL+T6mVqwrqRrbkgybVBhIucUE7Fg8yKpAQb5cpcNd343jwWT5K+pa+DH nRW1wp7zQWkJu5Plz3UGg/69CQHzS2VBfxmFAXflezRHXts2a9i7wZzGLwtX+gQeiM2yR cWwjOeuEdveXFfdnKX4esi65JCTatWG1xc0xA22b2Ju8Slx0GyEA5O4OD0zcLIgCcEA== 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=QbsbpU8A; arc=none smtp.remote-ip=209.85.160.72 Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.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 04D41606A330 for ; Fri, 4 Dec 2026 19:24:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 04D41606A330 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=QbsbpU8A Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-469debb526fso1133117fac.0 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=lists.linux.dev; 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=QbsbpU8A/Plsa5kgpCIXJck28ZzaoM01726sqT8jbx86kqDfrJz6mGrQY1KUnypqRZ H2MICxrZEvS23Y7WL7pcDD1Z7ZJOdbo4Ue0uMdnkh2Cdvvty+RFS6sX/Pi5FwNw28rKw MjNhkU88kKIzE65DxciHr+9FJDGrSFnOJ8ZQQi0mLZs0Ocx2CInrSf1P9thH6vhnIyGg FWWHHTl4InRSA2o2B6k7EV2YLsYlY08UJC/AeuMQI2n6v7CJS7Bo3uSHq7W1+N7+dD0k kt/mmi4hTXHW+FayiqEX6aSd3629K43ivjpQxjtrvycr/uBD76CMzQEg4cjE+xFRRZQn scBQ== 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=PEyq+hVcVEbQe7j5VfCLxA1vReJrktCmG+uV9JdVAmCNerdLtFEdlqA3itIPVDXn7c mgA4XK8TwrTXLzn1n2+4GUob+X7NSNI6FwNdySuZpqsqgPCCh3K4CeEDXNk0Ty+x0cA8 Oz7rMTRgV8ha31YDlcxYbjV2AGkdOEMH0Kr7cM0ArYnmO/eoyMVndh+6DFTVJt8dJoDd eOcs/bB5h2g/4Le60fvlWtRFY+S9459/3HI8gX1wG5VxQ0FiW65iJ1GCVSsGWjhxJK9G o4E1POoJkZvo5JHUDWJk7FCuAW1qmy1/jRFJnhp+Xfnoes+duikaeYZupE+NarAjIN5a yERg== X-Forwarded-Encrypted: i=1; AL+hErF/8s7uJKTTUa/q/6HL/mGSe3463MkXC9Kbb0C0NdCY2OQHIRl9CjKUCYnE6dN0zZsEEU1i@lists.linux.dev X-Gm-Message-State: APuU4Z+CKGf03nmVsiaRzPUPzin5GugfqRBotyXAfgXWrG9Jk/LHv61v eNIP0ZbH/Mb0vEX0A4a+SwpOYWtBcE1HP/shYSQqo0e2QLeil/9B68HUays+0dIkPjSg529uJes itDb/0sapPtiwN88+9KE7GvNwjg== 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: llvm@lists.linux.dev 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