Skip to content

Commit

Permalink
clocksource/drivers: Fix uninitialized variable use in timer_of_init
Browse files Browse the repository at this point in the history
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: dc11bae ("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
  • Loading branch information
Arnd Bergmann authored and Thomas Gleixner committed Jun 21, 2017
1 parent 17d9d68 commit b7dcc4e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/clocksource/timer-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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:
Expand All @@ -168,5 +167,5 @@ int __init timer_of_init(struct device_node *np, struct timer_of *to)

if (flags & TIMER_OF_BASE)
timer_base_exit(&to->of_base);
goto out;
return ret;
}

0 comments on commit b7dcc4e

Please sign in to comment.