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=1796413142; b=dPZlO0uB4Zq9MP/90lC2Quo0VOju1rumuLM1CCW/zFx/ioy7tWdN/e6dh1bL9Yr5JCRL bm9fYmrXNJlPHvQtqk5APjkZKxPdT4kh+TYIHZV4XMu5tBmEN+jTnF6QU/7PIVw3pwGis DhzY5Ex9AuaQTzppnmuMWHk2RXB1TW7CQTHq/SDxBECpZ8NKx+O99uksOhiqB+A63Tj0E pR2w4i6IrJiZ0cYqMNdgsW/Fp2krttT4v2QzfGF1eYRwz9EW96WOtP3Fwrwf068M8F7++ w4/k22Dqzj/JVDdQ7po1gxqOXE4cZwiT8lsWJ7SMNGNYvlh+kh15YDjplKk/qLRurnw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796413142; 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=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=uWZJFRrlnrou2/A/YtbpF/QbD/rV/0QpWR8PsIE9dzTQxEai1IwyYeiX6MJCGhthGYzn TMVdOWQkRN+nANLzTPNojlfMWjSnJ0eaKTwCXbAQTj9roCEumFNhzGql9zDz35cxOx471 gkSKp4R1RRFZlnEZi7jtU+u5rkOWMKzq708T+KI9rvrGGyLonE8jIHnpLawt01BrBfrBH 8Lu/033866XYoszNuIPcR6gmNZLMyS4UIeRVvOdLk+owdDuHf6EA4/w5pdzXWvJbee/z0 1WhaW5pvJdl++hwco+3OuO8zvPVHAEtX+1y/yXXfmnhdPu0ozzBGK7G5JAuEc2KVDTA== 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=NABwvjba; 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 E27E2606A32C for ; Fri, 4 Dec 2026 19:39:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E27E2606A32C 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=NABwvjba Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-85d630e451aso1374916a34.2 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=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=UrNpBmfONNhXcMAx0C7yOAlZ1FIhvM+giHax68+f7CY=; b=NABwvjbaEl1r9Ixt26BQaq6w3iLuooc4DowY9xCgVez4qV5PtF4mA3vUQ01Upg4AuW 96XtUY2atIEzKLh1K+MzWfUihUOeXhAU/f4i/FOjfN/LnoQgAgYv/K1kfSQAxSm/Tzmx JLiEJlif5rxytOpIzCzEjj0/JdFv5gh2a7KdxLg5xHy3oP5YTl8hwUih5lhVWDyZ/1/1 wfl6oYZ0boi55hcQIdd00Yuo3ZdZCkZsEBvWB2XlAatIBRMVat5S3Qzqd9ZFO1jQG8CX 84dS25BtpucxY69zSEbmatkjDHQSgntPRv9bE60eoqxm7KRmMo5fVQauc5TRlXKdzats WV0g== 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=188QabkL5shdLNWfebQnXUH72+bj45yE32+kWAcT+AKbgbocbSuR9T7TUGTiUNoCIE nCDwlzXUFM6BDjJMIP5bQxP+xGuct9aY0Ioa+hDSxLKrLyLuhtZ075FcIuvvd1Saux0I nJB6kMxt6oHFrmNa/Gyh3cW/e/FLaZlt5W0wKKv0Yn/wdV77IbbBPQpqmG83dvcwV9K8 RkVe4Jrq5YZSsVYJog4DqzIquNnp5qtXCJosqKBSD9J/SHV2O/GiAM2a8rtWVkiW9m2I +jlYJdAPOOlYtyGoQWu+8Uio6mSnDLJNcHKYMcNZ4N7qDY2mRQgybIY6XfEfElC+UqZE +RMQ== X-Forwarded-Encrypted: i=1; AL+hErGdvjIFuoSPmPDAMGdIwRC4Tpv8D8nANYJeIU4QWftF3AY1qWFZZ+i/k/TtOP8sKLbiBVgemJQ=@vger.kernel.org X-Gm-Message-State: APuU4Z8MWnZTNDH+u4nihDezs0Bcr2q8uLXPK47QoYDzy3CXJ/EOi8KN OQAHahsau8g1G4YMTrglnualOeJ2TL8HE7enKi4zCo/8dLNSKmRFGXJi9Zla5Mewyo/ByCqi62P cK1vFB7F9yt1oNZmkKLp0RNrBsA== 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-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-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 Content-Type: text/plain; charset="us-ascii" 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