Skip to contentSkip to conversation

clk: versatile: off by one in clk_sp810_timerclken_of_get()

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 29, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: versatile: off by one in clk_sp810_timerclken_of_get()

The ">" should be ">=" or we end up reading beyond the end of the array.

Fixes 6e973d2c4385 ('clk: vexpress: Add separate SP810 driver')
drivers/clk/versatile/clk-sp810.c +2 -2
index 64b0129..7fbe4d4 100644
@@ -129,8 +129,8 @@ static struct clk *clk_sp810_timerclken_of_get(struct of_phandle_args *clkspec,
 {
 	struct clk_sp810 *sp810 = data;
 
-	if (WARN_ON(clkspec->args_count != 1 || clkspec->args[0] >
-			ARRAY_SIZE(sp810->timerclken)))
+	if (WARN_ON(clkspec->args_count != 1 ||
+		    clkspec->args[0] >=	ARRAY_SIZE(sp810->timerclken)))
 		return NULL;
 
 	return sp810->timerclken[clkspec->args[0]].clk;
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dan Carpenter

The ">" should be ">=" or we end up reading beyond the end of the array.

Fixes 6e973d2c4385 ('clk: vexpress: Add separate SP810 driver')
drivers/clk/versatile/clk-sp810.c +0 -0
index 64b0129..7fbe4d4 100644

drivers/clk/versatile/clk-sp810.c static struct clk *clk_sp810_timerclken_of_get(struct of_phandle_args *clkspec, · line 136

Quoted 10 lines
drivers/clk/versatile/clk-sp810.c +2 -2
@@ -129,8 +129,8 @@ static struct clk *clk_sp810_timerclken_of_get(struct of_phandle_args *clkspec,
 {
 	struct clk_sp810 *sp810 = data;
 
-	if (WARN_ON(clkspec->args_count != 1 || clkspec->args[0] >
-			ARRAY_SIZE(sp810->timerclken)))
+	if (WARN_ON(clkspec->args_count != 1 ||
+		    clkspec->args[0] >=	ARRAY_SIZE(sp810->timerclken)))
 		return NULL;
 
 	return sp810->timerclken[clkspec->args[0]].clk;

Of course.

Thanks!

Pawel

Applied
#2 lore raw
In reply to Dan Carpenter

drivers/clk/versatile/clk-sp810.c

Quoted 8 lines · Dan Carpenter

The ">" should be ">=" or we end up reading beyond the end of the array.

Fixes 6e973d2c4385 ('clk: vexpress: Add separate SP810 driver')
drivers/clk/versatile/clk-sp810.c +0 -1
index 64b0129..7fbe4d4 100644
--- a/drivers/clk/versatile/clk-sp810.c

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project