* [PATCH v2] timer-of: handle of_irq_get_byname() result correctly
@ 2017-07-17 18:00 Sergei Shtylyov
2017-07-17 20:45 ` [tip:timers/urgent] clocksource/drivers/timer-of: Handle " tip-bot for Sergei Shtylyov
0 siblings, 1 reply; 2+ messages in thread
From: Sergei Shtylyov @ 2017-07-17 18:00 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner; +Cc: linux-kernel, Sergei Shtylyov
[-- Attachment #1: timer-of-handle-of_irq_get_byname-result-correctly-v2.patch --]
[-- Type: text/plain, Size: 1836 bytes --]
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: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
The patch is against the 'tip.git' repo's 'timers/core' branch.
Changes in version 2:
- fix the function name in the subject;
- fix the fat-fingered word in the description.
drivers/clocksource/timer-of.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Index: tip/drivers/clocksource/timer-of.c
===================================================================
--- tip.orig/drivers/clocksource/timer-of.c
+++ tip/drivers/clocksource/timer-of.c
@@ -41,8 +41,16 @@ static __init int timer_irq_init(struct
struct timer_of *to = container_of(of_irq, struct timer_of, of_irq);
struct clock_event_device *clkevt = &to->clkevt;
- of_irq->irq = of_irq->name ? of_irq_get_byname(np, of_irq->name):
- irq_of_parse_and_map(np, of_irq->index);
+ if (of_irq->name) {
+ 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) {
pr_err("Failed to map interrupt for %s\n", np->full_name);
return -EINVAL;
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip:timers/urgent] clocksource/drivers/timer-of: Handle of_irq_get_byname() result correctly
2017-07-17 18:00 [PATCH v2] timer-of: handle of_irq_get_byname() result correctly Sergei Shtylyov
@ 2017-07-17 20:45 ` tip-bot for Sergei Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Sergei Shtylyov @ 2017-07-17 20:45 UTC (permalink / raw)
To: linux-tip-commits
Cc: daniel.lezcano, tglx, hpa, linux-kernel, mingo, sergei.shtylyov
Commit-ID: 32f2fea6e77e64cd4045ec2d5deb879aada3b476
Gitweb: http://git.kernel.org/tip/32f2fea6e77e64cd4045ec2d5deb879aada3b476
Author: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
AuthorDate: Mon, 17 Jul 2017 21:00:44 +0300
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 17 Jul 2017 22:43:00 +0200
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: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: http://lkml.kernel.org/r/20170717180114.678825147@cogentembedded.com
---
drivers/clocksource/timer-of.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index f6e7491..d509b50 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -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 clock_event_device *clkevt = &to->clkevt;
- of_irq->irq = of_irq->name ? of_irq_get_byname(np, of_irq->name):
- irq_of_parse_and_map(np, of_irq->index);
+ if (of_irq->name) {
+ 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) {
pr_err("Failed to map interrupt for %s\n", np->full_name);
return -EINVAL;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-17 20:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-17 18:00 [PATCH v2] timer-of: handle of_irq_get_byname() result correctly Sergei Shtylyov
2017-07-17 20:45 ` [tip:timers/urgent] clocksource/drivers/timer-of: Handle " tip-bot for Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).