All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: mmp: Off by one in mmp_clk_add()
@ 2018-12-03 14:51 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-12-03 14:51 UTC (permalink / raw)
  To: Michael Turquette, Chao Xie; +Cc: Stephen Boyd, linux-clk, kernel-janitors

The > comparison should be >= or we write one element beyond the end of
the unit->clk_table[] array.

(The unit->clk_table[] array is allocated in the mmp_clk_init() function
and it has unit->nr_clks elements).

Fixes: 4661fda10f8b ("clk: mmp: add basic support functions for DT support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/clk/mmp/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/mmp/clk.c b/drivers/clk/mmp/clk.c
index ad8d483a35cd..ca7d37e2c7be 100644
--- a/drivers/clk/mmp/clk.c
+++ b/drivers/clk/mmp/clk.c
@@ -183,7 +183,7 @@ void mmp_clk_add(struct mmp_clk_unit *unit, unsigned int id,
 		pr_err("CLK %d has invalid pointer %p\n", id, clk);
 		return;
 	}
-	if (id > unit->nr_clks) {
+	if (id >= unit->nr_clks) {
 		pr_err("CLK %d is invalid\n", id);
 		return;
 	}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] clk: mmp: Off by one in mmp_clk_add()
@ 2018-12-03 14:51 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-12-03 14:51 UTC (permalink / raw)
  To: Michael Turquette, Chao Xie; +Cc: Stephen Boyd, linux-clk, kernel-janitors

The > comparison should be >= or we write one element beyond the end of
the unit->clk_table[] array.

(The unit->clk_table[] array is allocated in the mmp_clk_init() function
and it has unit->nr_clks elements).

Fixes: 4661fda10f8b ("clk: mmp: add basic support functions for DT support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/clk/mmp/clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/mmp/clk.c b/drivers/clk/mmp/clk.c
index ad8d483a35cd..ca7d37e2c7be 100644
--- a/drivers/clk/mmp/clk.c
+++ b/drivers/clk/mmp/clk.c
@@ -183,7 +183,7 @@ void mmp_clk_add(struct mmp_clk_unit *unit, unsigned int id,
 		pr_err("CLK %d has invalid pointer %p\n", id, clk);
 		return;
 	}
-	if (id > unit->nr_clks) {
+	if (id >= unit->nr_clks) {
 		pr_err("CLK %d is invalid\n", id);
 		return;
 	}
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] clk: mmp: Off by one in mmp_clk_add()
  2018-12-03 14:51 ` Dan Carpenter
@ 2018-12-03 17:55   ` Stephen Boyd
  -1 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2018-12-03 17:55 UTC (permalink / raw)
  To: Chao Xie, Dan Carpenter, Michael Turquette; +Cc: linux-clk, kernel-janitors

Quoting Dan Carpenter (2018-12-03 06:51:43)
> The > comparison should be >= or we write one element beyond the end of
> the unit->clk_table[] array.
> 
> (The unit->clk_table[] array is allocated in the mmp_clk_init() function
> and it has unit->nr_clks elements).
> 
> Fixes: 4661fda10f8b ("clk: mmp: add basic support functions for DT support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Applied to clk-fixes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] clk: mmp: Off by one in mmp_clk_add()
@ 2018-12-03 17:55   ` Stephen Boyd
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2018-12-03 17:55 UTC (permalink / raw)
  To: Chao Xie, Dan Carpenter, Michael Turquette; +Cc: linux-clk, kernel-janitors

Quoting Dan Carpenter (2018-12-03 06:51:43)
> The > comparison should be >= or we write one element beyond the end of
> the unit->clk_table[] array.
> 
> (The unit->clk_table[] array is allocated in the mmp_clk_init() function
> and it has unit->nr_clks elements).
> 
> Fixes: 4661fda10f8b ("clk: mmp: add basic support functions for DT support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Applied to clk-fixes


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-03 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 14:51 [PATCH] clk: mmp: Off by one in mmp_clk_add() Dan Carpenter
2018-12-03 14:51 ` Dan Carpenter
2018-12-03 17:55 ` Stephen Boyd
2018-12-03 17:55   ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.