linux/drivers/clk/samsung
Nathan Chancellor a317f63255 clk: samsung: exynos-clkout: Assign .num before accessing .hws
commit cf33f0b7df upstream.

Commit f316cdff8d ("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 exynos_clkout_probe() due to .num being assigned after .hws[]
has been accessed:

  UBSAN: array-index-out-of-bounds in drivers/clk/samsung/clk-exynos-clkout.c:178:18
  index 0 is out of range for type 'clk_hw *[*]'

Move the .num initialization to before the first access of .hws[],
clearing up the warning.

Cc: stable@vger.kernel.org
Fixes: f316cdff8d ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Reported-by: Jochen Sprickerhof <jochen@sprickerhof.de>
Closes: https://lore.kernel.org/aSIYDN5eyKFKoXKL@eldamar.lan/
Tested-by: Jochen Sprickerhof <jochen@sprickerhof.de>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-01-08 10:16:58 +01:00
..
clk-artpec8.c clk: samsung: artpec-8: Add initial clock support for ARTPEC-8 SoC 2025-08-31 15:22:33 +02:00
clk-cpu.c clk: samsung: cpu: convert from round_rate() to determine_rate() 2025-08-23 18:46:50 +02:00
clk-cpu.h clk: samsung: Add CPU clock support for Exynos850 2024-02-25 17:07:34 +01:00
clk-exynos-arm64.c clk: samsung: Implement manual PLL control for ARM64 SoCs 2024-03-26 09:58:32 +01:00
clk-exynos-arm64.h clk: samsung: exynos5433: Extract PM support to common ARM64 layer 2023-03-07 08:38:54 +01:00
clk-exynos-audss.c clk: samsung: Add missing mod_devicetable.h header 2025-03-07 16:01:19 +01:00
clk-exynos-clkout.c clk: samsung: exynos-clkout: Assign .num before accessing .hws 2026-01-08 10:16:58 +01:00
clk-exynos4.c clk: samsung: Use samsung CCF common function 2025-04-16 09:34:53 +02:00
clk-exynos5-subcmu.c clk: samsung: Add missing mod_devicetable.h header 2025-03-07 16:01:19 +01:00
clk-exynos5-subcmu.h clk: samsung: Change signature of exynos5_subcmus_init() function 2019-08-08 13:53:42 -07:00
clk-exynos7.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos850.c clk: samsung: exynos850: fix a comment 2025-06-10 10:21:24 +02:00
clk-exynos990.c clk: samsung: exynos990: Add PERIC0 and PERIC1 clock support 2025-09-07 11:12:45 +02:00
clk-exynos2200.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos3250.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos4412-isp.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos5250.c clk: samsung: Add missing mod_devicetable.h header 2025-03-07 16:01:19 +01:00
clk-exynos5260.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos5260.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
clk-exynos5410.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos5420.c clk: samsung: Add missing mod_devicetable.h header 2025-03-07 16:01:19 +01:00
clk-exynos5433.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos7870.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos7885.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynos8895.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynosautov9.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-exynosautov920.c clk: samsung: exynosautov920: add block hsi2 clock support 2025-06-12 17:28:11 +02:00
clk-fsd.c clk: samsung: fsd: Add clk id for PCLK and PLL in CAM_CSI block 2025-08-18 10:46:36 +02:00
clk-gs101.c clk: samsung: gs101: fix alternate mout_hsi0_usb20_ref parent clock 2025-06-10 10:21:21 +02:00
clk-pll.c clk: samsung: Add clock PLL support for ARTPEC-8 SoC 2025-08-31 15:22:30 +02:00
clk-pll.h clk: samsung: Add clock PLL support for ARTPEC-8 SoC 2025-08-31 15:22:30 +02:00
clk-s3c64xx.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk-s5pv210-audss.c clk: samsung: Add missing mod_devicetable.h header 2025-03-07 16:01:19 +01:00
clk-s5pv210.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk.c clk: samsung: Drop unused clk.h and of.h headers 2025-03-07 16:01:22 +01:00
clk.h clk: samsung: Add missing mod_devicetable.h header 2025-03-07 16:01:19 +01:00
Kconfig clk: samsung: add CONFIG_OF dependency 2023-06-12 11:45:20 +02:00
Makefile clk: samsung: artpec-8: Add initial clock support for ARTPEC-8 SoC 2025-08-31 15:22:33 +02:00