misc: vexpress: Off by one in vexpress_syscfg_exec()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 3 Dec 2018 14:52:19 +0000 (17:52 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Dec 2018 14:42:18 +0000 (15:42 +0100)
The > comparison should be >= to prevent reading beyond the end of the
func->template[] array.

(The func->template array is allocated in vexpress_syscfg_regmap_init()
and it has func->num_templates elements.)

Fixes: 974cc7b93441 ("mfd: vexpress: Define the device as MFD cells")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/vexpress-syscfg.c

index 6c3591c..a3c6c77 100644 (file)
@@ -61,7 +61,7 @@ static int vexpress_syscfg_exec(struct vexpress_syscfg_func *func,
        int tries;
        long timeout;
 
-       if (WARN_ON(index > func->num_templates))
+       if (WARN_ON(index >= func->num_templates))
                return -EINVAL;
 
        command = readl(syscfg->base + SYS_CFGCTRL);