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 63B13606A680 for ; Fri, 4 Dec 2026 19:40:17 +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=KDUE6/k8; 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=SJr3q5Ix 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=RgbvdS6hNTHufJeGX8+2t++Etb8EJCBTcxL6caCD1+I=; b=KDUE6/k8plbL14xRydHhrnuNsd PZfoqH43kwcrcnw3G58fqn4IdijkvCYH8ZR0D9ntOtDSmFnNElEvSSwh+K1B8owh2wDXDWjKyCRmi 1kjw5Axn8XKaWBx0JJnJ2iCQw1gz0qHfK07PbvJQa3LQs/PDlzuN2/x+W6EZsM4sVAL+46TfLBPBd K1p81SZviJ/faGY1yJ5ej3UvOGClYCfhmAxSMu/C5a+q52aQg2XuaVFy1A24mIYg+XiDE7qHh8GUp u8ffDUsYdmY0z03zm1O6ZT11kNHbSMZBebVc1UKn/jXCRtypELv03scwlTE4rgsdwufA6OwDRhYK5 LSx+qWtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZ8K-00000001JuK-1GAp; Fri, 04 Dec 2026 19:39:52 +0000 Received: from mail-ot1-x346.google.com ([2607:f8b0:4864:20::346]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZ7d-00000001Jks-2rCZ for linux-riscv@lists.infradead.org; Fri, 04 Dec 2026 19:39:24 +0000 Received: by mail-ot1-x346.google.com with SMTP id 46e09a7af769-863475627f7so1528766a34.0 for ; Fri, 04 Dec 2026 11:39:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796413141; x=1797017941; 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=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=SJr3q5IxKPwPQJWUno9CN8rG82ThxLkmkm3POSi2COfh1i0sN0P40N1lbIsKD/Nn9i FjgDl2ergA94O4NDJVpsdBU5nMZE033widO4AQCU7MzABXqtB6+svF6+ic8mNgQF9qYg Dhrat0CKklMdZ6bzJJVTenuwDrArZEDExzwtTBtbonFJEG197HpZEQr6qPKiPorlOFji djLyMTql0iLbyCVIwKBSvMOuFv6REflqibH9b6uQ1fA5mLGo6y319ER8ae10JhJtU6ZI m6ASxpN3odo52TRIzqcxgqWdckVKogv2B2gDDxhQvVBNH7/VFfxXO3jBh3bGLgyfaRTu zMqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796413141; x=1797017941; 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=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=xW4YlqKyi3hNx6OglKozTtd/tX4/m8mtTZ6bbeABbZNALGtyO2gbUXJ9PWS7cG6SD2 G1KIMk65DjhjKKF7dKtz6Z2mw/FwwShEI94gEjlP2nFDIwSEHa0l6EvoH7Fiwa+0EPgm 27F4gLOsMZ4LO+UdihkKJXHsKSNbpplLxLf7Es/XKh2L06fdocPC5gT3uee8rIz3IDzx O9WG8hM5EMw+rn/YBxw93w8XtVxVhUIU+Hl4KF3QhPG90+UGoXORWYXkUPSkK1Pz+M6f vVTwe5IZe89ETwCAKldnMFYguJiV3igSRdB0Vmpj1mUJpEDCpx+92ynSO6PIFybJzF7c C/hg== X-Forwarded-Encrypted: i=1; AL+hErEMLiDJTi4ORypZIsZYiGFzcPnSbgl1jyGkxfHlMaePS1W/fhWQi9hyIbW/s4yUT9ATSpdFI59RPLK9fw==@lists.infradead.org X-Gm-Message-State: APuU4Z9pN5roWsHWIR2YSZE8ht8L2cQizBKKqqYmhsuk9Sa895QAqyXY CVoN0WxRDQURgOvJSthHIf+09fAt53I4PWMnnAlWaDIeLafDB9XobqregugX0Y4bZHZwoGh7iPq HahDFib2teyWduXiivU9fJEVtNg== X-Received: from iocrb20-n2.prod.google.com ([2002:a05:6602:a594:20b0:9cb:4cd1:ccdf]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:339b:10b0:71b:c1a8:c924 with SMTP id 006d021491bc7-71bf2072031mr2175134eaf.19.1796413140797; Fri, 04 Dec 2026 11:39:00 -0800 (PST) Date: Fri, 4 Dec 2026 11:39:00 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-10-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-10-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 10/11] clk: bm1880: 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_113914_548724_6D9E09A3 X-CRM114-Status: GOOD ( 17.98 ) 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:48PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but bm1880_clk_probe() 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 before the loop that fills hws[]. > > 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/clk-bm1880.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/clk/clk-bm1880.c b/drivers/clk/clk-bm1880.c > index dc13d90bdd919..e2511991eeea2 100644 > --- a/drivers/clk/clk-bm1880.c > +++ b/drivers/clk/clk-bm1880.c > @@ -893,12 +893,11 @@ static int bm1880_clk_probe(struct platform_device *pdev) > > clk_data->pll_base = pll_base; > clk_data->sys_base = sys_base; > + clk_data->hw_data.num = num_clks; > > for (i = 0; i < num_clks; i++) > clk_data->hw_data.hws[i] = ERR_PTR(-ENOENT); > > - clk_data->hw_data.num = num_clks; > - > bm1880_clk_register_plls(bm1880_pll_clks, > ARRAY_SIZE(bm1880_pll_clks), > clk_data); > > -- > 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