Skip to content

Commit

Permalink
clk: mmp: Off by one in mmp_clk_add()
Browse files Browse the repository at this point in the history
The > comparison should be >= or we write one element beyond the end of
the unit->clk_table[] array.

(The unit->clk_table[] array is allocated in the mmp_clk_init() function
and it has unit->nr_clks elements).

Fixes: 4661fda ("clk: mmp: add basic support functions for DT support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Dan Carpenter authored and Stephen Boyd committed Dec 3, 2018
1 parent d9f5b7f commit 2e85c57
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/clk/mmp/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void mmp_clk_add(struct mmp_clk_unit *unit, unsigned int id,
pr_err("CLK %d has invalid pointer %p\n", id, clk);
return;
}
if (id > unit->nr_clks) {
if (id >= unit->nr_clks) {
pr_err("CLK %d is invalid\n", id);
return;
}
Expand Down

0 comments on commit 2e85c57

Please sign in to comment.