Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1504122 > unrolled thread

[PATCH] clk: uniphier: fix memory overrun bug

Started byMasahiro Yamada <yamada.masahiro@socionext.com>
First post2016-10-19 18:40 +0200
Last post2016-10-19 22:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] clk: uniphier: fix memory overrun bug Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-10-19 18:40 +0200
    Re: [PATCH] clk: uniphier: fix memory overrun bug Stephen Boyd <sboyd@codeaurora.org> - 2016-10-19 22:20 +0200

#1504122 — [PATCH] clk: uniphier: fix memory overrun bug

FromMasahiro Yamada <yamada.masahiro@socionext.com>
Date2016-10-19 18:40 +0200
Subject[PATCH] clk: uniphier: fix memory overrun bug
Message-ID<su24j-3OH-51@gated-at.bofh.it>
The first loop of this "for" statement writes memory beyond the
allocated clk_hw_onecell_data.

It should be:
    for (clk_num--; clk_num >= 0; clk_num--)
            ...

Or more simply:
    while (--clk_num >= 0)
            ...

Fixes: 734d82f4a678 ("clk: uniphier: add core support code for UniPhier clock driver")
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/clk/uniphier/clk-uniphier-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c
index f4e0f6b..84bc465 100644
--- a/drivers/clk/uniphier/clk-uniphier-core.c
+++ b/drivers/clk/uniphier/clk-uniphier-core.c
@@ -79,7 +79,7 @@ static int uniphier_clk_probe(struct platform_device *pdev)
 	hw_data->num = clk_num;
 
 	/* avoid returning NULL for unused idx */
-	for (; clk_num >= 0; clk_num--)
+	while (--clk_num >= 0)
 		hw_data->hws[clk_num] = ERR_PTR(-EINVAL);
 
 	for (p = data; p->name; p++) {
-- 
1.9.1

[toc] | [next] | [standalone]


#1504312

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-10-19 22:20 +0200
Message-ID<su5vb-6ae-1@gated-at.bofh.it>
In reply to#1504122
On 10/19, Masahiro Yamada wrote:
> The first loop of this "for" statement writes memory beyond the
> allocated clk_hw_onecell_data.
> 
> It should be:
>     for (clk_num--; clk_num >= 0; clk_num--)
>             ...
> 
> Or more simply:
>     while (--clk_num >= 0)
>             ...
> 
> Fixes: 734d82f4a678 ("clk: uniphier: add core support code for UniPhier clock driver")
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---

Applied to clk-fixes

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web