From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796413209; b=J5161Vlm9+484widngkw1pI7AqC3qnc8rYSuISbPP55dbH+PC6flhAkgtmSATTyGerla WMp1iIEAHw7jvf8gEcX1pSeYJ5N13LErcYCUfF3Ydq64l2xFwjQKYRB/3roIXMPt2qA+U +ijLG9k0k8iPn6/U7DN7Bnh72+g7DpiYa1ZrztjErPbZRbbJFqZRGZ3Wqy6alNu1LHXPH JHS7i+nV6I5FgZ2GDoqjOR9YtHxAczQMy87IQdQdZPEiqi8LH3HrK6G85xHa71sLj75/4 Mh+dwk63uypzGehjCiTfde4J5Wc2/XjQhv6jG2En+aPOHiBZdcSo2darSCLJdBVx3CQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796413209; 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=R/igBZ83mnWCJbUY7lCksfSr3EtqQgrQSJqASpb7DFUPPTU6P9fGGo7SGnolvirzlFeX oDYPmC315tzpUZID47mzC52wARxPQ8H2WUpMjIPQ1VAKAW6b2iYnSNp86oklWwd53ZYEd qbHofUOEVOim0oa3K2omiRgmS9zQYdpXsfcOPYEZXeL/CUoXxEFolBMge0ZfTc47+giDh gDSbvGJddWAq9JsmS2E2FAVZfc1qqa2nxyxfZc8KWVXctWh/YLcPRzC1SoSk6jvgHpNI3 tBxij15y71QxgF9zY3axJKJfYi+elc6GRAJ0mKakF1TCw3W/Ay8yaiBCu0lJP1gXNnQ== 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=WqlCpemT; arc=none smtp.remote-ip=209.85.161.71 Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (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 03F88606A6A6 for ; Fri, 4 Dec 2026 19:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 03F88606A6A6 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=WqlCpemT Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-71aca016fdcso1767148eaf.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=vger.kernel.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=WqlCpemTtaZ2gh3fc6LVquK8DZUfWXTcOHWYqTYbaL8CEVewhM9Km+ucdKQqIaoRCi IzAWZv1EvkHTeDJPPuLzRRgDLrRBzzZemmL1WP5INQLw1sS+b2J+/4BkDGKQAuKMvMXE njTkHxjpew/Wl2eGEdv+FpzGpaX5RdFBNQqet8KFkf8KVW+WdHC3S9JHJi6ysj21zQ3L MOIEC9Wokk6qisRjwD3ufDRCMTwm0dBH4HQ8N2JmYitYouBewE6rpwCM5bX855w65mP+ aNXEHY6PNt+gO1nfQqgHkC3HxscHTk1Dn23zagrHv2/j4X8a+43sDivk7/0IeZqvb4aE w8ig== 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=ZIBTbU2JnCRwNU4gi71ME/UqsDci1YurugE5FzbdWVRUzGe4ayZeBqKVeh0okG+67r mW3sFvOdr3Wm4BgT5qa6fStbXANNIPxZvln1Rhx/+w9kZtNbKXJ7Aa8rVw7WbI7ZIPmR QGQFQaXlRR68YR+9t0s+8RlwG3oNvL9zf/fUEsKLRd1G/tg3/NKO0d1ZrXiIQGpAH5jp TsgELld0QAHp3EAR8jqwSfBgIHb9adYbhUxyK7hk7skqBdxYBgIvoA4yR/WTsVkVgrOG OUZhgqM+N2g+fQTjcRcoGt6zV0eXq1iVOaRfvd0vTbbQR6i+pJfICX2ljBwEIuMynfQ7 zlCg== X-Forwarded-Encrypted: i=1; AL+hErHSTFAxbOMwq8wyUlEmHcBMvRecWObhQkKNTCUKN2K36vvHCGcDzc9+dNp2XQ4N4DMPEK0v1RY=@vger.kernel.org X-Gm-Message-State: APuU4Z+Z1KpEcGc2U8LIT2yXPVU002ckBXJLmXaSfVQcCn28vW+sRAn6 ApoVrh+Vwetxb30VoifLQ9XqTcr6+mu1rqNwKntAm0JQIA87nUaaK22DZl38axu1evC9kn7LVKq uF6jblKRtLM+GFEw0f5cZiRXFuQ== 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: stable@vger.kernel.org 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