Skip to content

Commit aacc875

Browse files
xiaoleiwang123456bebarino
authored andcommitted
clk: imx: Fix an out-of-bounds access in dispmix_csr_clk_dev_data
When num_parents is 4, __clk_register() occurs an out-of-bounds when accessing parent_names member. Use ARRAY_SIZE() instead of hardcode number here. BUG: KASAN: global-out-of-bounds in __clk_register+0x1844/0x20d8 Read of size 8 at addr ffff800086988e78 by task kworker/u24:3/59 Hardware name: NXP i.MX95 19X19 board (DT) Workqueue: events_unbound deferred_probe_work_func Call trace: dump_backtrace+0x94/0xec show_stack+0x18/0x24 dump_stack_lvl+0x8c/0xcc print_report+0x398/0x5fc kasan_report+0xd4/0x114 __asan_report_load8_noabort+0x20/0x2c __clk_register+0x1844/0x20d8 clk_hw_register+0x44/0x110 __clk_hw_register_mux+0x284/0x3a8 imx95_bc_probe+0x4f4/0xa70 Fixes: 5224b18 ("clk: imx: add i.MX95 BLK CTL clk driver") Cc: [email protected] Reviewed-by: Frank Li <[email protected]> Signed-off-by: Xiaolei Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 6306e0c commit aacc875

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/clk/imx/clk-imx95-blk-ctl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,15 @@ static const struct imx95_blk_ctl_dev_data lvds_csr_dev_data = {
219219
.clk_reg_offset = 0,
220220
};
221221

222+
static const char * const disp_engine_parents[] = {
223+
"videopll1", "dsi_pll", "ldb_pll_div7"
224+
};
225+
222226
static const struct imx95_blk_ctl_clk_dev_data dispmix_csr_clk_dev_data[] = {
223227
[IMX95_CLK_DISPMIX_ENG0_SEL] = {
224228
.name = "disp_engine0_sel",
225-
.parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", },
226-
.num_parents = 4,
229+
.parent_names = disp_engine_parents,
230+
.num_parents = ARRAY_SIZE(disp_engine_parents),
227231
.reg = 0,
228232
.bit_idx = 0,
229233
.bit_width = 2,
@@ -232,8 +236,8 @@ static const struct imx95_blk_ctl_clk_dev_data dispmix_csr_clk_dev_data[] = {
232236
},
233237
[IMX95_CLK_DISPMIX_ENG1_SEL] = {
234238
.name = "disp_engine1_sel",
235-
.parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", },
236-
.num_parents = 4,
239+
.parent_names = disp_engine_parents,
240+
.num_parents = ARRAY_SIZE(disp_engine_parents),
237241
.reg = 0,
238242
.bit_idx = 2,
239243
.bit_width = 2,

0 commit comments

Comments
 (0)