diff options
| author | André Draszik <[email protected]> | 2025-03-26 12:08:00 +0000 |
|---|---|---|
| committer | Stephen Boyd <[email protected]> | 2025-05-08 21:01:44 +0000 |
| commit | 3e14c7207a975eefcda1929b2134a9f4119dde45 (patch) | |
| tree | 45d0fc9d9a22bd34b9b76c51b44e1fcbd3e2832b /tools/testing/selftests/net/lib/py/netns.py | |
| parent | Merge tag 'v6.15-rockchip-clkfixes1' of git://git.kernel.org/pub/scm/linux/ke... (diff) | |
| download | kernel-3e14c7207a975eefcda1929b2134a9f4119dde45.tar.gz kernel-3e14c7207a975eefcda1929b2134a9f4119dde45.zip | |
clk: s2mps11: initialise clk_hw_onecell_data::num before accessing ::hws[] in probe()
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: [email protected]
Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Signed-off-by: André Draszik <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Stephen Boyd <[email protected]>
Diffstat (limited to 'tools/testing/selftests/net/lib/py/netns.py')
0 files changed, 0 insertions, 0 deletions
