* [PATCH] drivers: clk: clk-en7523.c: Initialize num before accessing hws in en7523_register_clocks
@ 2024-12-03 14:29 Haoyu Li
2024-12-03 22:53 ` Stephen Boyd
2024-12-04 2:36 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Haoyu Li @ 2024-12-03 14:29 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, Kees Cook, Gustavo A . R . Silva,
linux-clk, linux-kernel, linux-hardening
Cc: stable, Haoyu Li
With the new __counted_by annocation in clk_hw_onecell_data, the "num"
struct member must be set before accessing the "hws" array. Failing to
do so will trigger a runtime warning when enabling CONFIG_UBSAN_BOUNDS
and CONFIG_FORTIFY_SOURCE.
Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
---
drivers/clk/clk-en7523.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
index e52c5460e927..61d95ead5ec4 100644
--- a/drivers/clk/clk-en7523.c
+++ b/drivers/clk/clk-en7523.c
@@ -503,6 +503,8 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_dat
u32 rate;
int i;
+ clk_data->num = EN7523_NUM_CLOCKS;
+
for (i = 0; i < ARRAY_SIZE(en7523_base_clks); i++) {
const struct en_clk_desc *desc = &en7523_base_clks[i];
u32 reg = desc->div_reg ? desc->div_reg : desc->base_reg;
@@ -524,8 +526,6 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_dat
hw = en7523_register_pcie_clk(dev, np_base);
clk_data->hws[EN7523_CLK_PCIE] = hw;
-
- clk_data->num = EN7523_NUM_CLOCKS;
}
static int en7523_clk_hw_init(struct platform_device *pdev,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: clk: clk-en7523.c: Initialize num before accessing hws in en7523_register_clocks
2024-12-03 14:29 [PATCH] drivers: clk: clk-en7523.c: Initialize num before accessing hws in en7523_register_clocks Haoyu Li
@ 2024-12-03 22:53 ` Stephen Boyd
2024-12-04 2:36 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2024-12-03 22:53 UTC (permalink / raw)
To: Gustavo A . R . Silva, Haoyu Li, Kees Cook, Michael Turquette,
linux-clk, linux-hardening, linux-kernel
Cc: stable, Haoyu Li
Quoting Haoyu Li (2024-12-03 06:29:15)
> With the new __counted_by annocation in clk_hw_onecell_data, the "num"
> struct member must be set before accessing the "hws" array. Failing to
> do so will trigger a runtime warning when enabling CONFIG_UBSAN_BOUNDS
> and CONFIG_FORTIFY_SOURCE.
>
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
>
> Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
> ---
Applied to clk-fixes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: clk: clk-en7523.c: Initialize num before accessing hws in en7523_register_clocks
2024-12-03 14:29 [PATCH] drivers: clk: clk-en7523.c: Initialize num before accessing hws in en7523_register_clocks Haoyu Li
2024-12-03 22:53 ` Stephen Boyd
@ 2024-12-04 2:36 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2024-12-04 2:36 UTC (permalink / raw)
To: Haoyu Li; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] drivers: clk: clk-en7523.c: Initialize num before accessing hws in en7523_register_clocks
Link: https://lore.kernel.org/stable/20241203142915.345523-1-lihaoyu499%40gmail.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-04 2:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 14:29 [PATCH] drivers: clk: clk-en7523.c: Initialize num before accessing hws in en7523_register_clocks Haoyu Li
2024-12-03 22:53 ` Stephen Boyd
2024-12-04 2:36 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox