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=1796412552; b=HeI7kjYSacuQOHsEwJtay5VzjZ475uyIflU3i6CC6xYGkYJBiE9/uusX/rzYlobhMne4 29tIDDsZzNACOusMMWOUfCTUjAD9D7M1KIuNO+XTT0fj5w5MeYHBIQd3GEK7mCYiEKdX8 mYOLTqzCC0wA72ElgyG5zi0BboLuS+ClrOLFywk/kZrvWgmOuizsNm7vsxoas2ZbmHu9F RwYw2o+kYJeWUEp9gP6ot9/hAjemGwfOGKfpIgdE5pajlJC5YhhADqIgPbD5j4wPD6RXz vTmRA6BRh7xWJnPZGrbRQdHCKQlfq2aAP8kdPyCWB+oo47FubX7U9t5JvT7jw9I/qPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412552; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=G0BIt7d/bXz2WvJ9FRx1RLUHWm7+Ccu6J6mNKU/jXT+kNZXL++YMFaZCfPbOagVI5POY aZJw2NMOEEviO0YPgsefO9KaB0mHNoen1lClKV3WqQNfFzTHX/nL0Db6GoWtlhYT5UHbH s+epcIX7whLpcxASay0PIKymxBx6QTs8LFUzUdSB8WKyO3l6UKHC7kAn4JD/O7OQyE9gG FDI7ql9VIDitzhZep54Qq3sETA3iS45+fu01qc0FwDCBpj0eohHmVm1vuOzKB8hQ/wQe2 eVHnMR0cqV6DerKF12hIAvvaATGGw15UYOaHxv1N09r8f1nk8OolXp8Uq10Lz23Penw== 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=dM0A6+13; 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 29B5D606A32F for ; Fri, 4 Dec 2026 19:29:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 29B5D606A32F 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=dM0A6+13 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-6e1fc036608so893894eaf.0 for ; Fri, 04 Dec 2026 11:29:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796412551; x=1797017351; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=dM0A6+13mPG1hfGTPWoYZxgWpgHiKQh13wJpcMDVc6AmNTW8iuzNzAqijPReTxBt3E I+7TUiCNZFi0mtERixYZC0xSqeaxug/bxtA46TiJeTzfR4N4eG9tfj3Gxg4v1ks7f3is N2z4arptBQLogWx/5n0vdNvW9eQoLFzYqE34zgy603oNWT7GenAbEWE0jJuKbW9lXyov VAqkK+Wucw6BxJg7VkHoDaFD3qoVp1dTT0oUsmQD4Ny58PXpnZozU+LsnyvQ/6t7zlXi s60t1cTALOB68uRBmEQ8wDM4wfbjamiFn17Uuh/fPANco2ND2j2nw79FV/4TXF1JXEz4 iIwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796412551; x=1797017351; 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=i0p0p2uCeHnJCZP1bF4nsgy1JMncUB/5KkPcrMOQQlk=; b=KSnXi0cZhpJLMecFqPyDkC/vBjYx7UToTSqhqjB79/G2kegPpFoUcuAb9ek/UyyspE VznXbOXxhTkoqxpivDp/Gqst8ER2ZoMYjJsYc/y53eWyKqT1yR89fAhSB2+5EomZEzgZ TPjRl0R8j3QNiJCiIICqFp86aeKEMdlQZdypYi4uSWZNeRDtliWWHvCq1Ab561Z/pBjg ndWnsKuSsy2Fqp24i/xWmUVKRVKt4MLBdcOtNVchdu0AUNr0AVt0Vmxn+b9UbJHSbr4z 0K7o/tBnwof8T7vL/2NIm9c1PIHeN3lUZQ+sQsqZz7eGwSBoUR6gxBkXW5uhjWSafwrY Lc4w== X-Forwarded-Encrypted: i=1; AL+hErFou8irI6hlpqmDiMjqJ7vsFFoxcSnK7zxmSYLsZuqRd87uqbjW6i80KLf4Wm9UGnidClZF@lists.linux.dev X-Gm-Message-State: APuU4Z+inw2+MwZz+UkHGYGmexj7NkV1zhBPlEMjDwpk/8B0ux9oIFpe Y4i5qbubUwTIByOSq1RG9rLoY3XgU+6bzspSIAyqFedxLzW8WCX4tzxcTQgdnA8vTT4fgqAdfga 0syPlrMbZT3IkM8h5Mwj+PZe8cQ== X-Received: from jabge8.prod.google.com ([2002:a05:6638:6808:b0:621:d390:8d01]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1692:b0:71b:7bd3:8a77 with SMTP id 006d021491bc7-71bf1ad52aemr2665572eaf.6.1796412550766; Fri, 04 Dec 2026 11:29:10 -0800 (PST) Date: Fri, 4 Dec 2026 11:29:10 -0800 In-Reply-To: <20261203-clk-onecell-count-order-v1-5-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-5-2b0e4e8d9ea6@cressey.dev> Message-ID: Subject: Re: [PATCH 05/11] clk: visconti: 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:43PM -0800, Ben Cressey wrote: > hws[] is annotated with __counted_by(num), but visconti_init_clk() 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 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/visconti/clkc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/visconti/clkc.c b/drivers/clk/visconti/clkc.c > index a75163b69751e..f8bb93d7027bc 100644 > --- a/drivers/clk/visconti/clkc.c > +++ b/drivers/clk/visconti/clkc.c > @@ -195,9 +195,9 @@ struct visconti_clk_provider *visconti_init_clk(struct device *dev, > if (!ctx) > return ERR_PTR(-ENOMEM); > > + ctx->clk_data.num = nr_clks; > for (i = 0; i < nr_clks; ++i) > ctx->clk_data.hws[i] = ERR_PTR(-ENOENT); > - ctx->clk_data.num = nr_clks; > > ctx->dev = dev; > ctx->regmap = regmap; > > -- > 2.56.0 > Reviewed-by: Justin Stitt Justin