Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp999151ybp; Fri, 4 Oct 2019 08:08:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB8tWdn96rhYnAD0bCdYBLh0hRb2TcQtm+MsZaSC0DDuV7SiUoJBjbl7LrUL7ELoaVMlmq X-Received: by 2002:a17:906:1f57:: with SMTP id d23mr13134019ejk.103.1570201733080; Fri, 04 Oct 2019 08:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570201733; cv=none; d=google.com; s=arc-20160816; b=dv0qaW7T4fKeLwtXkcnPZ7//z2VIhCbeoF6eYshQbnQJERyEkOalptfU7UxTeb2+wq 9Kj7Gaa1QGPEj3yNpmaC3rcWMXcZJtQjTTDsBZohkCQ+FUzloOl+OzRxptmKA0Ie+X4c hhag3rw1ExSKVTMPyT24GaIVQ0VS6N7JKNrHP21aiCG5uli1OFFryMyehc1t85lRgLAL sLUU8r8EbJiJtHWNIeufiR5eJzv6morkWYA6e8t9xRuub3QQXSiCSVg5627pf7Id5dFN 2GKVS/n3W3kxcwliPyX/81u+mi/zX8/occR7Nnn7h6kJqh/x4tv2sMroYrQZWY+2Zcib pc9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature; bh=xIMt13mG94hCnwq9tB5hFbt6P6pHx2A1tw5PR55u2hg=; b=HXhD+ZMtvMmTCF0oCvxuyzTJf36rVegFttC8xhPaJx6o+Pm/61D1AouXDHapBFBjNX P+4h9KIbgOrGEk8LBU5jTWMc5WTRZGEE9caQUlpPfPP5B4r3sAe3FQ2I98wQkhYZkRHi nsUpBRAW4h47eqShBv5NO2MmkGZt6/w5zpjTV9SENvlfwDYFpm2S5vDRr6s6e17pQG1I FdKSvK49sT/J2LLCwfimf3xUhIO7gl2ePCILf7ddujQ1qFpXQmw0hOthI15bPVfG92ln X+ZgmRVRSOcnswEJ4PvWmbUIV+FPbc2B8XCWbU1M1Qxt8qdXolzvejTG8KPAEALpFn7n Ct8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2UDp5dGG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si3092201ejx.139.2019.10.04.08.08.28; Fri, 04 Oct 2019 08:08:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2UDp5dGG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389658AbfJDPHy (ORCPT + 99 others); Fri, 4 Oct 2019 11:07:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:50480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388802AbfJDPHw (ORCPT ); Fri, 4 Oct 2019 11:07:52 -0400 Received: from localhost.localdomain (unknown [194.230.155.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 693762133F; Fri, 4 Oct 2019 15:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570201671; bh=QJNtgzf3I7MaqgTwW24kwXRCqf/tm/P6Sh5Bo/9VnwA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=2UDp5dGGX/8FZNXAiEEBqoJAFgg5033UO0O6fs41817qSowaRVAFmPLAoNAzdNUfA kMA/TAU/YvtqPXUVIgec3b6V5kJLk80ctVeIpX8TdaF00KqX8iJkt5/+xsHnISBlRU nBhxCvmbyupeqamN5SvFZLpmyDrbtTJzKOJqLNak= From: Krzysztof Kozlowski To: Sebastian Reichel , Krzysztof Kozlowski , "Gustavo A. R. Silva" , Linus Walleij , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFT 3/3] power: supply: ab8500: Handle invalid IRQ from platform_get_irq_byname() Date: Fri, 4 Oct 2019 17:07:38 +0200 Message-Id: <20191004150738.6542-3-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191004150738.6542-1-krzk@kernel.org> References: <20191004150738.6542-1-krzk@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org platform_get_irq_byname() might return -errno which later would be cast to an unsigned int and used in request_irq(). Signed-off-by: Krzysztof Kozlowski --- Not marking as cc-stable as this was not reproduced and not tested. --- drivers/power/supply/ab8500_btemp.c | 5 +++++ drivers/power/supply/ab8500_charger.c | 5 +++++ drivers/power/supply/ab8500_fg.c | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index a167938e32f2..cfd8152bf8fc 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -1082,6 +1082,11 @@ static int ab8500_btemp_probe(struct platform_device *pdev) /* Register interrupts */ for (i = 0; i < ARRAY_SIZE(ab8500_btemp_irq); i++) { irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name); + if (irq < 0) { + ret = irq; + goto free_irq; + } + ret = request_threaded_irq(irq, NULL, ab8500_btemp_irq[i].isr, IRQF_SHARED | IRQF_NO_SUSPEND, ab8500_btemp_irq[i].name, di); diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index e51d0e72beea..7ad23df6f75a 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -3556,6 +3556,11 @@ static int ab8500_charger_probe(struct platform_device *pdev) /* Register interrupts */ for (i = 0; i < ARRAY_SIZE(ab8500_charger_irq); i++) { irq = platform_get_irq_byname(pdev, ab8500_charger_irq[i].name); + if (irq < 0) { + ret = irq; + goto free_irq; + } + ret = request_threaded_irq(irq, NULL, ab8500_charger_irq[i].isr, IRQF_SHARED | IRQF_NO_SUSPEND, ab8500_charger_irq[i].name, di); diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 7d879589adc2..01f3da103813 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -3151,6 +3151,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) /* Register primary interrupt handlers */ for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq_th); i++) { irq = platform_get_irq_byname(pdev, ab8500_fg_irq_th[i].name); + if (irq < 0) { + ret = irq; + goto free_irq_th; + } + ret = request_irq(irq, ab8500_fg_irq_th[i].isr, IRQF_SHARED | IRQF_NO_SUSPEND, ab8500_fg_irq_th[i].name, di); @@ -3166,6 +3171,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) /* Register threaded interrupt handler */ irq = platform_get_irq_byname(pdev, ab8500_fg_irq_bh[0].name); + if (irq < 0) { + ret = irq; + goto free_irq_th; + } + ret = request_threaded_irq(irq, NULL, ab8500_fg_irq_bh[0].isr, IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_ONESHOT, ab8500_fg_irq_bh[0].name, di); -- 2.17.1