Commit 32f2fea6 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Thomas Gleixner

clocksource/drivers/timer-of: Handle of_irq_get_byname() result correctly

of_irq_get_byname() may return a negative error number as well as 0 on
failure, while timer_irq_init() only checks for 0, blithely continuing with
the call to request_[percpu_]irq() -- those functions expect *unsigned int*,
so would probably fail anyway when a large IRQ number resulting from a
conversion of a negative error number is passed to them... This, however,
is incorrect behavior -- error number is not IRQ number.

Filter out the negative error numbers, complain, and return them to the
timer_irq_init()'s callers...

Fixes: dc11bae7 ("clocksource/drivers: Add timer-of common init routine")
Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: http://lkml.kernel.org/r/20170717180114.678825147@cogentembedded.com
parent 935acd3f
...@@ -41,8 +41,16 @@ static __init int timer_irq_init(struct device_node *np, ...@@ -41,8 +41,16 @@ static __init int timer_irq_init(struct device_node *np,
struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); struct timer_of *to = container_of(of_irq, struct timer_of, of_irq);
struct clock_event_device *clkevt = &to->clkevt; struct clock_event_device *clkevt = &to->clkevt;
of_irq->irq = of_irq->name ? of_irq_get_byname(np, of_irq->name): if (of_irq->name) {
irq_of_parse_and_map(np, of_irq->index); of_irq->irq = ret = of_irq_get_byname(np, of_irq->name);
if (ret < 0) {
pr_err("Failed to get interrupt %s for %s\n",
of_irq->name, np->full_name);
return ret;
}
} else {
of_irq->irq = irq_of_parse_and_map(np, of_irq->index);
}
if (!of_irq->irq) { if (!of_irq->irq) {
pr_err("Failed to map interrupt for %s\n", np->full_name); pr_err("Failed to map interrupt for %s\n", np->full_name);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment