Skip to content

Commit

Permalink
clk: zynqmp: Off by one in zynqmp_is_valid_clock()
Browse files Browse the repository at this point in the history
The > comparison should be >= to prevent reading beyond the end of the
clock[] array.

(The clock[] array is allocated in zynqmp_clk_setup() and has
clock_max_idx elements.)

Fixes: 3fde0e1 ("drivers: clk: Add ZynqMP clock driver")
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 2e85c57 commit 9a43be9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/clk/zynqmp/clkc.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static const struct zynqmp_eemi_ops *eemi_ops;
*/
static inline int zynqmp_is_valid_clock(u32 clk_id)
{
if (clk_id > clock_max_idx)
if (clk_id >= clock_max_idx)
return -ENODEV;

return clock[clk_id].valid;
Expand Down

0 comments on commit 9a43be9

Please sign in to comment.