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


Groups > linux.kernel > #1672097 > unrolled thread

[PATCH] clocksource/drivers: fix uninitialized variable use in timer_of_init

Started byArnd Bergmann <arnd@arndb.de>
First post2017-06-22 00:00 +0200
Last post2017-06-22 09:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] clocksource/drivers: fix uninitialized variable use in timer_of_init Arnd Bergmann <arnd@arndb.de> - 2017-06-22 00:00 +0200
    [tip:timers/core] clocksource/drivers: Fix uninitialized variable  use in timer_of_init tip-bot for Arnd Bergmann <tipbot@zytor.com> - 2017-06-22 00:10 +0200
    Re: [PATCH] clocksource/drivers: fix uninitialized variable use in  timer_of_init Daniel Lezcano <daniel.lezcano@linaro.org> - 2017-06-22 09:10 +0200

#1672097 — [PATCH] clocksource/drivers: fix uninitialized variable use in timer_of_init

FromArnd Bergmann <arnd@arndb.de>
Date2017-06-22 00:00 +0200
Subject[PATCH] clocksource/drivers: fix uninitialized variable use in timer_of_init
Message-ID<tUVPk-3BI-19@gated-at.bofh.it>
If none of the flags are set, 'ret' is uninitialized as pointed out
by gcc:

drivers/clocksource/timer-of.c: In function 'timer_of_init':
drivers/clocksource/timer-of.c:160:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Since calling the function without any of the flags is an error,
set the return value to -EINVAL for that case.

Fixes: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/clocksource/timer-of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index be1dbee11c20..af75cbdcfc06 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -130,7 +130,7 @@ static __init int timer_base_init(struct device_node *np,
 
 int __init timer_of_init(struct device_node *np, struct timer_of *to)
 {
-	int ret;
+	int ret = -EINVAL;
 	int flags = 0;
 
 	if (to->flags & TIMER_OF_BASE) {
-- 
2.9.0

[toc] | [next] | [standalone]


#1672119 — [tip:timers/core] clocksource/drivers: Fix uninitialized variable use in timer_of_init

Fromtip-bot for Arnd Bergmann <tipbot@zytor.com>
Date2017-06-22 00:10 +0200
Subject[tip:timers/core] clocksource/drivers: Fix uninitialized variable use in timer_of_init
Message-ID<tUVZ1-3Vj-33@gated-at.bofh.it>
In reply to#1672097
Commit-ID:  b7dcc4eacc45263ac5d3a0bd78c64e9ff7c94c13
Gitweb:     http://git.kernel.org/tip/b7dcc4eacc45263ac5d3a0bd78c64e9ff7c94c13
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Wed, 21 Jun 2017 23:49:54 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 22 Jun 2017 00:04:26 +0200

clocksource/drivers: Fix uninitialized variable use in timer_of_init

If none of the flags are set, 'ret' is uninitialized as pointed out
by gcc:

drivers/clocksource/timer-of.c: In function 'timer_of_init':
drivers/clocksource/timer-of.c:160:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Since calling the function without any of the flags is an error,
set the return value to -EINVAL for that case.

[ tglx: Get rid of the silly backwards goto while at it ]

Fixes: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: http://lkml.kernel.org/r/20170621215005.3870011-1-arnd@arndb.de

---
 drivers/clocksource/timer-of.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index be1dbee..64b1c20 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -130,7 +130,7 @@ static __init int timer_base_init(struct device_node *np,
 
 int __init timer_of_init(struct device_node *np, struct timer_of *to)
 {
-	int ret;
+	int ret = -EINVAL;
 	int flags = 0;
 
 	if (to->flags & TIMER_OF_BASE) {
@@ -156,7 +156,6 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)
 
 	if (!to->clkevt.name)
 		to->clkevt.name = np->name;
-out:
 	return ret;
 
 out_fail:
@@ -168,5 +167,5 @@ out_fail:
 
 	if (flags & TIMER_OF_BASE)
 		timer_base_exit(&to->of_base);
-	goto out;
+	return ret;
 }

[toc] | [prev] | [next] | [standalone]


#1672347 — Re: [PATCH] clocksource/drivers: fix uninitialized variable use in timer_of_init

FromDaniel Lezcano <daniel.lezcano@linaro.org>
Date2017-06-22 09:10 +0200
SubjectRe: [PATCH] clocksource/drivers: fix uninitialized variable use in timer_of_init
Message-ID<tV4pA-1l7-15@gated-at.bofh.it>
In reply to#1672097
On 21/06/2017 23:49, Arnd Bergmann wrote:
> If none of the flags are set, 'ret' is uninitialized as pointed out
> by gcc:
> 
> drivers/clocksource/timer-of.c: In function 'timer_of_init':
> drivers/clocksource/timer-of.c:160:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> Since calling the function without any of the flags is an error,
> set the return value to -EINVAL for that case.
> 
> Fixes: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---

Thanks for the fix!



-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web