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=1796413208; b=1fKNLY0B5SApmGxU7LB/yxYAS4BIEjYAtV9Mqh6PHdvzQkxrPJy9Y2ht8+ZZ6Oj+wduz LlZ9mnRIH9/WdT8YgwgdIgDSTvC+ccDSEXVGw6BO/HlEskBATj6tDR5Bn5I+hBi6Wn1Qq asS1VdKzqTdxG0tXw+oAAbj4kvEvJpEAjYe/ychk9zgjFf+DFC1im2xGCU7M+97ML/o3G lhFcIUevgJ7rmsZHUPBuVJeNf+fKKQ9Ogby0OP3ej9jFAgBTMABg2X78jgwl51do/hiZZ UwBvj6crvrC6hWoeaWwO2lq+6QP0b1XAf7lla80iEzhJgbAFfFmXXSUTkKWppWfnyXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796413208; 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=2qJHEybOfUDmEAavus/SRlCLHdMXub/Udw0V4rff2Z8=; b=OKCCb7/+ak9uQWuj1tysdKJBUfOwJptjXH3FgAM0Kwa7gW8xisXlUVlH43kEMuuz/wVD XavpYZITHFYyjGNYr+R7AxyGIOBlG1BeAhM7AG4sobjxOWFeMHBWkd8Et99zxXZn3BRqq N7xo/T1CSlwDZJ1WHu/MsoMWNzH/5PkxxEKCbkKJTACJKBfUO7L2T0L3RYJ0crxBTCRi3 cPPNJbbvCVzDYqFTgesanqe8WAeS/DZdzEsIAqWU5jRq403khdDxzdS54sFXTcpNI/qCR lzcbbiv4DB02UIShqxgWy9RBcbDfCv0REYx5C9s4ukg5g+aqEInzvX/fs7pbzo1cnyA== 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=lM9ckxoh; 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 0893D606A690 for ; Fri, 4 Dec 2026 19:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0893D606A690 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=lM9ckxoh Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-863475627f7so1530035a34.0 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.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=2qJHEybOfUDmEAavus/SRlCLHdMXub/Udw0V4rff2Z8=; b=lM9ckxohjAVAX1oU4x1dEeUWVIakbdw8kFwRaFptJHX/NVcFlubGjRqhu2bxkUUU9p IKWF8zeTdEGTeZLfnSv/VDOaFRVA6Cx8sQmFilyq89Iz1JF4GDzKfOPshaJWFOlx9ORG mJaf2ORjO2bpNWYcLZA9l4xELQi+xE2z+AgtAeJtfClF2a2teVfc35Y7vknRJaoRkmkg NwQVpU4Lkl63lSKhb/YyNZ79qIsuqSVPCvOIBBa9uIpOVI4mQcWE0AVwVSA67eVs6uww XXJkZJ08FotdzO0kbX9O5U2IokY/wiKSC7AVwAOtFVNYfNl7qmLmdVvX4P9w/S8ghh6v LsBw== 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=opxOJdjcseBVKAUmD0B5wR54F9/JKk6f+1mmix2HnZ1pXObWw6QMZ1aPFmxaUzis0l DtDSclJAwjKAPpVLNCEIvnshcj3S8kTHUQZyrcfQU2MUGmRn9yq0dn0dFjxV84nRxCSY tIFWfvjkl8vmJCg6hpz4vDpMTkSFNZmewyQ4uT0XluC3GfpY1cnTZJAaaoIgUulbPI8m iTxb3uXi8Ftzj1VEWwNBpPdech9QMz+JjW3S1/HMYyqAZ4yov0JUSlqc5bPJB//iB0Qi r7gpAcie6x27q9EDgevCyBia2+quArD2AUyztNTQLoTonXVF6KlbOwaZqLpM6oeck/ZN Fl1w== X-Forwarded-Encrypted: i=1; AL+hErFzUJy/E4PP88okly+mVc7HZVzLW+VBB3yl7i005762meY9p4CNa/4DHUArWGLQ4C0ZBm0h@lists.linux.dev X-Gm-Message-State: APuU4Z/FQ0m69NiCsZwhtKjKh2QMGW8q+c9qXAXVZ+jCp/bMeyJ2Opdx vbjaHYzmv3JCobqRCuTthfNec3wkFcaS6Yc5X747U3BWv/x2D3v/+7eVIMfFRD8wnAEwJO4QKw1 k3athFBDWcCs1BJ6ip0nLN6hlYg== 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-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-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 Content-Type: text/plain; charset="us-ascii" 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