clk: zynqmp: Off by one in zynqmp_is_valid_clock()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 3 Dec 2018 14:52:01 +0000 (17:52 +0300)
committerStephen Boyd <sboyd@kernel.org>
Mon, 3 Dec 2018 17:54:48 +0000 (09:54 -0800)
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>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/zynqmp/clkc.c

index 297f16a20bfc5d3bae8dd8806cc8585d851383c0..f65cc0ff76abdb630b0694eb7c3babcc2c46ff71 100644 (file)
@@ -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;