diff mbox series

clk: zynqmp: Off by one in zynqmp_is_valid_clock()

Message ID 20181203145200.o6gnv5fhuubfgg4u@kili.mountain (mailing list archive)
State Accepted, archived
Headers show
Series clk: zynqmp: Off by one in zynqmp_is_valid_clock() | expand

Commit Message

Dan Carpenter Dec. 3, 2018, 2:52 p.m. UTC
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: 3fde0e16d016 ("drivers: clk: Add ZynqMP clock driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/clk/zynqmp/clkc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Boyd Dec. 3, 2018, 5:55 p.m. UTC | #1
Quoting Dan Carpenter (2018-12-03 06:52:01)
> 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: 3fde0e16d016 ("drivers: clk: Add ZynqMP clock driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Applied to clk-fixes
diff mbox series

Patch

diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
index 297f16a20bfc..f65cc0ff76ab 100644
--- a/drivers/clk/zynqmp/clkc.c
+++ b/drivers/clk/zynqmp/clkc.c
@@ -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;