Commit 9a43be9c authored by Dan Carpenter's avatar Dan Carpenter Committed by Stephen Boyd

clk: zynqmp: Off by one in zynqmp_is_valid_clock()

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: 3fde0e16 ("drivers: clk: Add ZynqMP clock driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 2e85c574
...@@ -128,7 +128,7 @@ static const struct zynqmp_eemi_ops *eemi_ops; ...@@ -128,7 +128,7 @@ static const struct zynqmp_eemi_ops *eemi_ops;
*/ */
static inline int zynqmp_is_valid_clock(u32 clk_id) 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 -ENODEV;
return clock[clk_id].valid; return clock[clk_id].valid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment