From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751265AbdGPT4Q (ORCPT ); Sun, 16 Jul 2017 15:56:16 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:35506 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751230AbdGPT4O (ORCPT ); Sun, 16 Jul 2017 15:56:14 -0400 From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Message-Id: <20170716195609.570376795@cogentembedded.com> User-Agent: quilt/0.64 Date: Sun, 16 Jul 2017 22:55:45 +0300 To: Daniel Lezcano , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Sergei Shtylyov Subject: [PATCH] timer-of: handle of_irq_get() result correctly MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=timer-of-handle-of_irq_get-result-correctly.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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;