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 4664E606A330 for ; Fri, 4 Dec 2026 20:14:16 +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=C//Gxw9+; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=F6GOizV4 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=kL5HBDnVZZIxgDhDHBpIklDeGgKY0S3DQBxK2KT8PdM=; b=C//Gxw9+E4/gYqGqp8GZXWhSXK OeUfDY7pIaGkLT9C/JXIikT1kHccGieNBqXpvMYlsAHHlte7WJYX+J0AfTtydUfwrTa2TwulxINI3 QZGzuUSW7cC9xwK7LaCBcohT5l2GdjRANUQlY3mLD4ZDIBFoYdV99STz5rs1vTeOVvanFrRAYSBmu nKs42B554sb31ijGgBorY+2Nw5W8SJAjkxJbqHKeXXfKbqbTUqDWdGQAvh/EU3KmBSVO67a84V7Nf RnwKZufof2EgL5aFHl+nE6t0E/e8NlK/1+218KEI/jq/8Hi4J1ztcvm76QcsWmFrwTE5XGBFtGdxb zYCPidog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZ8t-00000001KCb-0YPn; Fri, 04 Dec 2026 19:40:27 +0000 Received: from mail-ot1-x345.google.com ([2607:f8b0:4864:20::345]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZZ8a-00000001Jxt-44Ir for linux-riscv@lists.infradead.org; Fri, 04 Dec 2026 19:40:18 +0000 Received: by mail-ot1-x345.google.com with SMTP id 46e09a7af769-8615bdcc5cfso1797572a34.3 for ; Fri, 04 Dec 2026 11:40:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796413207; x=1797018007; 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=2qJHEybOfUDmEAavus/SRlCLHdMXub/Udw0V4rff2Z8=; b=F6GOizV4CM1XoC1MiG2J9U2Ad73J/gb0jGGZbhtebhjYPIfobbbb4Bu7ITvjFNb879 H4QficTNH9nd7EyhK2w/bcqcnGoC+ZFW3XQAKBn4rSBmWFtMmHCHg9Z0XbBa0vqJMkHp hU2zM8bZ6IOF4aW+Nzwv1UWr1cjT5GTmqwPSb1XZbQuI/IRy35lZ9I1DNbmh1Q5CN+Ax wP62IrIsd2MifR4fHJlqgrY2c3st+1OcGwRXLeJQWED2d5H9XHH+rYUbOoso//Ii8RKh VzzBlap/H9hmTMvREdRjO6GFFrBRLWEoWW1xyT58jwqpOvljfMqL2BrvhtdWeiBSRBtm JDjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796413207; x=1797018007; 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=2qJHEybOfUDmEAavus/SRlCLHdMXub/Udw0V4rff2Z8=; b=doo7NICvEaQioEt/0uLAoXqY6ko4lejE5kmDNiZyS0pfFj1E+XRs4OWjDGvk5MlhAu VYG3zPrYyJyc26nrA3uyNJLLwhn15WdQ+kzBxYGBsHCxVhNBfmiAnll3MdTxFkd0noHg Olmoz2OnMwzInu+fvvmqPQKc8byu6AVdP2rfIeSWfM/h2tKFvghyIzaxEg8hru7BuYc4 57Tdt8bIXDY4j4ql+khKGs0OLdogMQ5DXxnct2B7cR+hiVGt8e7Nnyh1TWwPsyZe2HpZ HE2TqQRz6WFZ3OYMfjzkeavaEO61q+qDaAHcHa9SZSbUaRNPNRitH4b1hooDvfZozkxa D1xQ== X-Forwarded-Encrypted: i=1; AL+hErFynpeTFrOkReUzs8Q7kx8tnl/gfJyHO3XBCiSzPeniQp8zYREUsDz7TrcdqXWP86SEtA8nWDDNyJpCmA==@lists.infradead.org X-Gm-Message-State: APuU4Z+SJwulWKGVAx2a+lHL3C7rmgrPDuuF8A4BTnnm9lHuzZ30MS1a xme+lsylyB0f6LnSzpLwHHTVqCfxXGYMmFVUk4odFWjEB3g6qcayMqiFEfgVROCsI3SZxx/WF3Z +kujcxhMlDY9OlsJettwWV0xeDA== X-Received: from iofl6-n1.prod.google.com ([2002:a05:6602:8386:10b0:9e8:9d0f:5a50]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:c7ca:b0:717:163:aeac with SMTP id 006d021491bc7-71bf21b18edmr2298554eaf.68.1796413206774; Fri, 04 Dec 2026 11:40:06 -0800 (PST) Date: Fri, 4 Dec 2026 11:40:06 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-11-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-11-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 11/11] clk: zynqmp: 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_114014_198876_3098304B X-CRM114-Status: GOOD ( 18.32 ) 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:49PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but zynqmp_register_clocks() > fills it before zynqmp_clk_setup() sets num. The count is still zero > with Clang 20 and 21, where kzalloc_flex() does not set it, and on v6.6 > to v6.19, which use 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/zynqmp/clkc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c > index d62f1901d0ab5..88d1281c284b8 100644 > --- a/drivers/clk/zynqmp/clkc.c > +++ b/drivers/clk/zynqmp/clkc.c > @@ -762,6 +762,7 @@ static int zynqmp_clk_setup(struct device_node *np) > zynqmp_data = kzalloc_flex(*zynqmp_data, hws, clock_max_idx); > if (!zynqmp_data) > return -ENOMEM; > + zynqmp_data->num = clock_max_idx; > > clock = kzalloc_objs(*clock, clock_max_idx); > if (!clock) { > @@ -772,7 +773,6 @@ static int zynqmp_clk_setup(struct device_node *np) > zynqmp_get_clock_info(); > zynqmp_register_clocks(np); > > - zynqmp_data->num = clock_max_idx; > return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, zynqmp_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