Skip to content

Commit d9f5b7f

Browse files
Dan Carpenterbebarino
authored andcommitted
clk: mvebu: Off by one bugs in cp110_of_clk_get()
These > comparisons should be >= to prevent reading beyond the end of of the clk_data->hws[] buffer. The clk_data->hws[] array is allocated in cp110_syscon_common_probe() when we do: cp110_clk_data = devm_kzalloc(dev, sizeof(*cp110_clk_data) + sizeof(struct clk_hw *) * CP110_CLK_NUM, GFP_KERNEL); As you can see, it has CP110_CLK_NUM elements which is equivalent to CP110_MAX_CORE_CLOCKS + CP110_MAX_GATABLE_CLOCKS. Fixes: d3da3ea ("clk: mvebu: new driver for Armada CP110 system controller") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent d206e6b commit d9f5b7f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/clk/mvebu/cp110-system-controller.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ static struct clk_hw *cp110_of_clk_get(struct of_phandle_args *clkspec,
200200
unsigned int idx = clkspec->args[1];
201201

202202
if (type == CP110_CLK_TYPE_CORE) {
203-
if (idx > CP110_MAX_CORE_CLOCKS)
203+
if (idx >= CP110_MAX_CORE_CLOCKS)
204204
return ERR_PTR(-EINVAL);
205205
return clk_data->hws[idx];
206206
} else if (type == CP110_CLK_TYPE_GATABLE) {
207-
if (idx > CP110_MAX_GATABLE_CLOCKS)
207+
if (idx >= CP110_MAX_GATABLE_CLOCKS)
208208
return ERR_PTR(-EINVAL);
209209
return clk_data->hws[CP110_MAX_CORE_CLOCKS + idx];
210210
}

0 commit comments

Comments
 (0)