Skip to content

Commit

Permalink
clk: uniphier: fix memory overrun bug
Browse files Browse the repository at this point in the history
The first loop of this "for" statement writes memory beyond the
allocated clk_hw_onecell_data.

It should be:
    for (clk_num--; clk_num >= 0; clk_num--)
            ...

Or more simply:
    while (--clk_num >= 0)
            ...

Fixes: 734d82f ("clk: uniphier: add core support code for UniPhier clock driver")
Signed-off-by: Masahiro Yamada <[email protected]>
Signed-off-by: Stephen Boyd <[email protected]>
  • Loading branch information
masahir0y authored and bebarino committed Oct 19, 2016
1 parent d339748 commit 7d36b9c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/clk/uniphier/clk-uniphier-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static int uniphier_clk_probe(struct platform_device *pdev)
hw_data->num = clk_num;

/* avoid returning NULL for unused idx */
for (; clk_num >= 0; clk_num--)
while (--clk_num >= 0)
hw_data->hws[clk_num] = ERR_PTR(-EINVAL);

for (p = data; p->name; p++) {
Expand Down

0 comments on commit 7d36b9c

Please sign in to comment.