From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E70C3EC805; Fri, 9 Oct 2026 14:20:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555653; cv=none; b=N7iTcUeKvUkGCiOcOThrIszk/lnYnt99CRl3VCPaJMuGoAH58ocYOMy/zVG+WAA/wzxzPPNcB+M/zlQ0XSnAXBkfUJrbMgN+y63yGGPwd0Knh598t/hjUKSbbXBO9YwZKbSyk4ZKxIyn5f3iuNc6OJngRLoDLljrpNQaBTBxWpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555653; c=relaxed/simple; bh=wTRIa3lQfSRbOqb7vlwn5AJjjNyAxSVcBGQU6CvPzVI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ECoOqUKFErMrdKveBfhQPMYIw2+wczIxAnD4Lme8KbPc1mHosmnmrSPAY8uiRiAmX6uFeCweW0bnbTb2YXsG+sYPBz2ZELATbsfeT4/UVweqNogY7EZdeuO9PtiE7PUkGhMTEKJN/YPgxkj//r/YFJTdR404V5IZl17yQHlUSO8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Utv3QGFr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Utv3QGFr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4CA21F000FF; Fri, 9 Oct 2026 14:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791555651; bh=U4lHV2g11v9ovFUKo2LVZhnRaSGnTFfzSPcSVUpj/F0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Utv3QGFrQlYWKKv2njE+r9IdF3yu4EV4OW3mQjPzj+wZEQnCwelw91QYNQIfkS20w lFbLlq+hL2ICa2begSEB2po0oxzwz6G+bF0Pzy5ZlOOJulIJZphXXrGpzLOgZB9opE ICF6zxWQ4GeyZ3TfReyuDKgMRYLqw9u6tA4Qr6AA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Aamir Ahmed , Chen-Yu Tsai , "Gustavo A. R. Silva" , Alexandre Belloni Subject: [PATCH 7.2 043/428] rtc: ac100: Assign .num before accessing .hws Date: Fri, 9 Oct 2026 16:06:20 +0200 Message-ID: <20261009140947.049622040@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140946.008206689@linuxfoundation.org> References: <20261009140946.008206689@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aamir Ahmed commit 6a4117eee82dd85f11bf898bf66026764011eeb6 upstream. Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' with __counted_by, which informs the bounds sanitizer (UBSAN_BOUNDS) 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 initialized with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialization because the number of elements is zero. This occurs in ac100_rtc_register_clks() due to .num being assigned only after every clkout clock has been stored in .hws[]. With CONFIG_UBSAN_BOUNDS and a compiler that implements __counted_by (GCC 15.1+ or Clang 20.1+), this triggers an array-index-out-of-bounds report during probe, and with CONFIG_UBSAN_TRAP the first store traps. Initialize .num with AC100_CLKOUT_NUM, the number of elements .hws[] was allocated with, right after the allocation. That is the value the loop counter ends up at on the success path anyway, so the provider's behaviour is unchanged. Cc: stable@vger.kernel.org Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") Assisted-by: LLM Signed-off-by: Aamir Ahmed Reviewed-by: Chen-Yu Tsai Reviewed-by: Gustavo A. R. Silva Link: https://patch.msgid.link/AS8P251MB00013E724A77A355668B6CCEC8B42@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM Signed-off-by: Alexandre Belloni Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-ac100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/rtc/rtc-ac100.c +++ b/drivers/rtc/rtc-ac100.c @@ -317,6 +317,8 @@ static int ac100_rtc_register_clks(struc if (!chip->clk_data) return -ENOMEM; + chip->clk_data->num = AC100_CLKOUT_NUM; + chip->rtc_32k_clk = clk_hw_register_fixed_rate(chip->dev, AC100_RTC_32K_NAME, NULL, 0, @@ -360,7 +362,6 @@ static int ac100_rtc_register_clks(struc chip->clk_data->hws[i] = &clk->hw; } - chip->clk_data->num = i; ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, chip->clk_data); if (ret) goto err_unregister_rtc_32k;