From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81439606A322 for ; Fri, 4 Dec 2026 19:25:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ZgfXsL4Z; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=YgQK6P8U DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Unsubscribe-Post:List-Owner; bh=dxGE7Ri+T10fAgPz9SRevPwx19sQQHtSLD1Oy1Ck+cg=; b=ZgfXsL4ZS8/fEljZNRAxJgswME 92Y6Ydp2//WmZUMsd/e6APWvxp+bNfsao97EvF0wFE+40RYTLafkvUO5FYNMUE1we14mEkXyzcoFm Lh7mKAZHC4DgkezW/dK2LCUIOdMCtn3c7iGcUKWn7t/X0mQQb0Zq1E0CmKPP0inU/uC2vf/ODtZKv RgvqQn2Mr32J78LEgAfMDdl3ImoxSBpItQ/gz5ezCVRD27L/ZNz+T9NjAKJZ6iJgGW5gQgrGPwQ03 qZl+lyohUb9NJ4bsycsWakLGWr4W1C6oBc/cDX9fpQ3xRqB4/sAl0tNgcY69wBctRhlZl3XmJ7Omx hs2WMgoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZYtp-00000001HNp-0hBW; Fri, 04 Dec 2026 19:25:05 +0000 Received: from mail-oa1-x46.google.com ([2001:4860:4864:20::46]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZYtb-00000001HK7-0pek for linux-riscv@lists.infradead.org; Fri, 04 Dec 2026 19:24:51 +0000 Received: by mail-oa1-x46.google.com with SMTP id 586e51a60fabf-458326d2d9aso1482001fac.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=lists.infradead.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=YgQK6P8UqmSRSvwtixWivyuVK2QcU4CkWKmZO/SPpoJV0j7BxUsxaOk1FFlx+Yn4yl LY9qYbQFm9LHmqfQ5HjVbVIgsI4zuvsvbzdcK9zs+qOOlCSDC2xyb7yvrhapbQgj8IX6 Ql19Ozxq0a3pO7zySyJLF73xEbfzrRZvHF4IT7BeBPSSBkxnVIme/zn5RS+WbgVsmRyT i7x36qevlnxkOvWYEsvstHbHoLv67GRuWOCbkFkg21/DisOaBxHY965/LJriXJ7Talp1 sa/lrb8m5BcjSM4n2qbCy9Y/jmioexSYkqjoQujzLMdB5YZYHOMDgOKF9ynDFEenajwU qaDA== 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=Pw8coI5RyUfMLWqyKpKcttpMh3gLo8hKIiGeYEY3WYLX0jMo/wngH+9LchRfUvVqQ8 IKih+hWotuVeE0QAXDx+HlTiAk9htK4F1Mg4gUhxoq8P/o3iucNGYbEZA/LD1j7MaTPo TWsAy/6YYz5466VAqBOk7vHY9Si0bOexs49qPIrAJVbjVYqhKQ+TfiwPIoJAyicMTqLh LOh9aF+rZBIcrVJ9BOdxMMt0pVK3LmL4w5ld+zEBapy5kxMZzg0tMTXGP95W/KL5Ufqs fPJsY7I+1B3GDAmv6rsSH5Tshb6X13s7lghpkz5qTA3S56i0DAp3yc5FhH+zOWhxf8OH ZD1A== X-Forwarded-Encrypted: i=1; AL+hErFf++ERVHuO2UMoDTgaoWc+hSsMuCSl3Wsk+ohdv1zR9OPAUDMDlWONkOXCzPHVvL4ATDqvAhtlqo9sQA==@lists.infradead.org X-Gm-Message-State: APuU4Z/tSAsBoZrSD0i2Dvg2Lfuj8xxyXIwFrIJnh2nyRxuYt7we5AmV hxNH+PxhNAN1nMNrH9dEdJHwcCPO0e0fwklnBHfYcRKei/Mql1zER8v6TtSuVAhSzTAnqqV9iGF 0vUjq/uErE2ilZkc9KR+PoEyqDw== 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-Archived-By: 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_112439_266727_FE354097 X-CRM114-Status: GOOD ( 18.35 ) X-Spam-Score: -9.5 (---------) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv