]> git.baikalelectronics.ru Git - kernel.git/commit
clk: mvebu: Off by one bugs in cp110_of_clk_get()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 3 Dec 2018 14:50:55 +0000 (17:50 +0300)
committerStephen Boyd <sboyd@kernel.org>
Mon, 3 Dec 2018 17:54:48 +0000 (09:54 -0800)
commitaf312ee816dbd57ed1850032f39a3b4483c610df
tree330ad61d8ab70cba2b2769d41e58823258157b32
parent85e4e29f17fd354f8779baae3d71578d44aaef33
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: 7f018e660481 ("clk: mvebu: new driver for Armada CP110 system controller")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/mvebu/cp110-system-controller.c