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


Groups > linux.kernel > #1688522 > unrolled thread

[PATCH] timer-of: handle of_irq_get() result correctly

Started bySergei Shtylyov <sergei.shtylyov@cogentembedded.com>
First post2017-07-16 22:00 +0200
Last post2017-07-17 19:20 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] timer-of: handle of_irq_get() result correctly Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2017-07-16 22:00 +0200
    Re: [PATCH] timer-of: handle of_irq_get() result correctly Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2017-07-17 19:20 +0200

#1688522 — [PATCH] timer-of: handle of_irq_get() result correctly

FromSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date2017-07-16 22:00 +0200
Subject[PATCH] timer-of: handle of_irq_get() result correctly
Message-ID<u3XRT-3jE-3@gated-at.bofh.it>
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.

Fileter 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 patcn is against the 'tip.git' repo's 'timers/core' branch.

 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;

[toc] | [next] | [standalone]


#1689286

FromSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date2017-07-17 19:20 +0200
Message-ID<u4hQB-7W1-7@gated-at.bofh.it>
In reply to#1688522
Hello!

On 07/16/2017 10:55 PM, Sergei Shtylyov wrote:

> 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.
>
> Fileter out the negative error numbers, complain, and return them to the

    Oops, a typo. And the subject should have of_irq_get_byname(). I'll repost.

> timer_irq_init()'s callers...
>
> Fixes: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
[...]

MBR, Sergei

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web