From patchwork Sun Jul 16 17:52:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 9843559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2F1C3602BD for ; Sun, 16 Jul 2017 17:52:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08880274D2 for ; Sun, 16 Jul 2017 17:52:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F027527813; Sun, 16 Jul 2017 17:52:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C469274D2 for ; Sun, 16 Jul 2017 17:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751230AbdGPRwv (ORCPT ); Sun, 16 Jul 2017 13:52:51 -0400 Received: from mail-lf0-f44.google.com ([209.85.215.44]:34243 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751216AbdGPRwu (ORCPT ); Sun, 16 Jul 2017 13:52:50 -0400 Received: by mail-lf0-f44.google.com with SMTP id t72so75086455lff.1 for ; Sun, 16 Jul 2017 10:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:user-agent:date:to:cc:subject:mime-version :content-disposition; bh=3fGyj9L2uDGvKMBY95MC1R+qXWpHEqjONFOew2ZS28M=; b=aKtGaucQ4XSYb5GusntwDf7+2/Y76KJ4T83NVIwx2lRUKn7pQ93t3wlxXfC0WR3fOd XihwIkHgcqBj/9fI30ePeivzS5JFEiDCMZpducB1MQxLP0wUmJC1Q1fJxlDKTVvztGWb Ud+zaF4X0AECuKPEIYGIH0O9B+v9NJmA5iwizamxb3mM/+D19ZE/u/KVz7nFoEcCb6k3 Cm0WTx/d2BcGMgXVgRi41Sp/AQVTzbjjrPvNzELnvwrmgblMXLmDiXdAstJUMFvfCjgE umv1kF04KqzLz+J1hhtn3byS7GYXGH/D9aSTF73P9vXfiJn1uNJ2rAf4PKX1chOXMG43 tbsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:user-agent:date:to:cc:subject :mime-version:content-disposition; bh=3fGyj9L2uDGvKMBY95MC1R+qXWpHEqjONFOew2ZS28M=; b=b8CMkgzAB/NKgLLqVgV3B5DurTyn3EQli0x6UX5291DGTZx5OyB9d8vwoqDb5B+o5f /UJsHdaePZFtEffupirofHK96hbC/ixWSpRJewBbUxTu42TQE4xmyARxRLySU6z9HawC BLnpfgnZKkQdGY7MOvsvZdJCOA4B4RjhnK2i9TGkZH3B8KHFv+ypsfLh3YxLnUaGK16r AO72dUllVcTcThAgftMsSPieXJwX44/zOugtVrlFVeso+kEFRw4QBKN6NNeF51hOHgT9 S3f21WrabLcaAs2Gbc9x1+lhFBLVTKSJCjWVsp28t6vUxKN5Pp9GGrlzoQmPQwXX31Dw Fy3A== X-Gm-Message-State: AIVw111IMVNJGhSuQAVgRkKj0yuAR66QkkLtUkKZpYZcBNXd0Mr/hGjJ 6oB0YpZ0ZgmWPq/jgkUoYA== X-Received: by 10.25.216.82 with SMTP id p79mr5807753lfg.35.1500227569162; Sun, 16 Jul 2017 10:52:49 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.83.220]) by smtp.gmail.com with ESMTPSA id 136sm3273335ljf.29.2017.07.16.10.52.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Jul 2017 10:52:47 -0700 (PDT) From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Received: by wasted.cogentembedded.com (sSMTP sendmail emulation); Sun, 16 Jul 2017 20:52:44 +0300 Message-Id: <20170716175244.300670810@cogentembedded.com> User-Agent: quilt/0.64 Date: Sun, 16 Jul 2017 20:52:20 +0300 To: Sebastian Reichel , linux-pm@vger.kernel.org Cc: Wenyou Yang , Sergei Shtylyov Subject: [PATCH] power: supply: act8945a_charger: fix of_irq_get() error check MIME-Version: 1.0 Content-Disposition: inline; filename=power-supply-act8945a_charger-fix-of_irq_get-error-check.patch Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_irq_get() may return any negative error number as well as 0 on failure, while the driver only checks for -EPROBE_DEFER, blithely continuing with the call to devm_request_irq() -- that function expects *unsigned int*, so would probably fail anyway when a large IRQ number resulting from a conversion of a negative error number is passed to it... This, however, is incorrect behavior -- error number is not IRQ number. Check for 'irq <= 0' instead and return -ENXIO from probe if of_irq_get() returned 0. Fixes: a09209acd6a8 ("power: supply: act8945a_charger: Add status change update support") Signed-off-by: Sergei Shtylyov --- drivers/power/supply/act8945a_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Index: linux/drivers/power/supply/act8945a_charger.c =================================================================== --- linux.orig/drivers/power/supply/act8945a_charger.c +++ linux/drivers/power/supply/act8945a_charger.c @@ -596,9 +596,9 @@ static int act8945a_charger_probe(struct return ret; irq = of_irq_get(pdev->dev.of_node, 0); - if (irq == -EPROBE_DEFER) { + if (irq <= 0) { dev_err(&pdev->dev, "failed to find IRQ number\n"); - return -EPROBE_DEFER; + return irq ?: -ENXIO; } ret = devm_request_irq(&pdev->dev, irq, act8945a_status_changed,