From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387511; b=lSUAKshrPMGKxacVPYYi0BOD4fxn7tOgOnWQ6sRmfYRgcvGMp8apOyvwYvid5j/yuYGV NK5PLq05HDuOnCYQlo7l7AxylStfFR9aUJG+DGbmrFBZ2RneIBldeDGo5rYFWDPOTSrHP 2VqyKOC+tI958PB/tDzryVx7KpKfxSoKx4kNQJdDao1RwJvgRdTIT+VZYTqv+XtUPoTXr yxwVyHv1OrXmRlfx4uCBCEjEkpy1v39TdqcEYuFE7zgX8B9ujYgDQmKsYlaadPaot41d7 6RbwtdymOAMs+bI6NCiiLRlpOVB8mS6sXrEsbUDlhipekt22R/IoGlA+JxUHP6a/WWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387511; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=8qx5ZPXIPHyxY/H+sIKalNAaqEKrqgCbrsf2gj9OH9Y=; b=2JAx26asYoZqsM4bSUUDiLPk8l+kNQjOj90evSf1Xv+d1qKCpaZx9JQ45nShs/QUeIiz nbkKa47uYZBA5eTincPTZw+/CDjX2Nh2QiRCCZqU9q0XM56WXf84XrAZL1u9myde4JzHy tSSE1XDC3yIUUJLHJNhfe5xljO86601zD3SEKq1tGdV8SkVzHrvS40Q52IncE2S2C76MZ B3OMMOvcQc3IBobXsIf6fMSliDSkyc4NCmO4+SFM8G6r6rkggJvYCUnxl+nwDTmBSOzt/ d3npp14d48Xa8J18O7Bhcbzt8haBzfVchH8SdOA9b8h0xXy9BZG4kMD7SK5mODIl/wg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=supHqmso; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 694CC606A337; Fri, 4 Dec 2026 12:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=supHqmso Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F7151F00933; Fri, 4 Dec 2026 12:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387511; bh=8qx5ZPXIPHyxY/H+sIKalNAaqEKrqgCbrsf2gj9OH9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=supHqmsoWNTkjiiRwTWXIrcaevmyZ19brbjZBYmZtB5VkBSF2xWjpE7F7oNlS5gi1 Tnam82vsNAi9/xsQqZAUDzlnIR/+4lHuvEPFpISdFqmWb7/yrn9Dj9Akn+xyq9p349 6MZAgPAv1pZYO6I1ve3UKP+40GjKvIVEAadrgE2Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Andr=C3=A9=20Draszik?= , Krzysztof Kozlowski , Stephen Boyd , Sasha Levin Subject: [PATCH 6.1 0273/1059] clk: s2mps11: initialise clk_hw_onecell_data::num before accessing ::hws[] in probe() Date: Fri, 4 Dec 2026 18:56:44 +0900 Message-ID: <20261204100651.343348925@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: André Draszik [ Upstream commit 3e14c7207a975eefcda1929b2134a9f4119dde45 ] With UBSAN enabled, we're getting the following trace: UBSAN: array-index-out-of-bounds in .../drivers/clk/clk-s2mps11.c:186:3 index 0 is out of range for type 'struct clk_hw *[] __counted_by(num)' (aka 'struct clk_hw *[]') This is because commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of that struct with __counted_by, which informs the bounds sanitizer about the number of elements in hws, so that it can warn when hws is accessed out of bounds. As noted in that change, the __counted_by member must be initialised with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialisation because the number of elements is zero. This occurs in s2mps11_clk_probe() due to ::num being assigned after ::hws access. Move the assignment to satisfy the requirement of assign-before-access. Cc: stable@vger.kernel.org Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") Signed-off-by: André Draszik Link: https://lore.kernel.org/r/20250326-s2mps11-ubsan-v1-1-fcc6fce5c8a9@linaro.org Reviewed-by: Krzysztof Kozlowski Signed-off-by: Stephen Boyd Stable-dep-of: 276741aac3b5 ("clk: s2mps11: Propagate OF provider registration failures") Signed-off-by: Sasha Levin --- drivers/clk/clk-s2mps11.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c index a3e883a9f4067..d89bd36529b45 100644 --- a/drivers/clk/clk-s2mps11.c +++ b/drivers/clk/clk-s2mps11.c @@ -137,6 +137,8 @@ static int s2mps11_clk_probe(struct platform_device *pdev) if (!clk_data) return -ENOMEM; + clk_data->num = S2MPS11_CLKS_NUM; + switch (hwid) { case S2MPS11X: s2mps11_reg = S2MPS11_REG_RTC_CTRL; @@ -186,7 +188,6 @@ static int s2mps11_clk_probe(struct platform_device *pdev) clk_data->hws[i] = &s2mps11_clks[i].hw; } - clk_data->num = S2MPS11_CLKS_NUM; of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get, clk_data); -- 2.53.0