From patchwork Sun Nov 12 15:52:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pan Bian X-Patchwork-Id: 10054825 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 AB7E460365 for ; Sun, 12 Nov 2017 15:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AD5E29597 for ; Sun, 12 Nov 2017 15:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F676295FD; Sun, 12 Nov 2017 15:52:31 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 1F80729597 for ; Sun, 12 Nov 2017 15:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751249AbdKLPw1 (ORCPT ); Sun, 12 Nov 2017 10:52:27 -0500 Received: from m12-14.163.com ([220.181.12.14]:57846 "EHLO m12-14.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220AbdKLPw0 (ORCPT ); Sun, 12 Nov 2017 10:52:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=H9ycIuW1cG0maCPEi5 x5/ldDwzIXCzol8AhjHHpXDi8=; b=P5oSr+seGoYWpveHs41v7LzVO34gEXKo5P pIwm70lEYM5KPkTJI5HrtUoUOKFMy7ab9nUv0duO8cTUKWFVw2JnV7dRwp+ArUj8 QLRc6a597Ftxntfhq7Wo1zd9Mj8W87LGOcGT63Aufwy4rjhqafF5CgFNO0DJYGel QxdICsqws= Received: from localhost.localdomain (unknown [106.120.213.14]) by smtp10 (Coremail) with SMTP id DsCowACX2cYjbghagIIDDA--.59255S3; Sun, 12 Nov 2017 23:52:10 +0800 (CST) From: Pan Bian To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] power: supply: cpcap-charger: fix incorrect return value check Date: Sun, 12 Nov 2017 23:52:02 +0800 Message-Id: <1510501922-19163-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DsCowACX2cYjbghagIIDDA--.59255S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xw4DuryfWF48tFyUCFy8Krg_yoWDJrgE93 y2g3929r4F9Fn0vwn0qF4fAF92kryxWrnrWF4ktF13Za4a9wsYv397ZFn5XF48Wry3CrWq 9FZYkFs3AryfJjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0znmtUUUUU== X-Originating-IP: [106.120.213.14] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQA+OclSIT6qCCgABsD 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 Function platform_get_irq_byname() returns a negative error code on failure, and a zero or positive number on success. However, in function cpcap_usb_init_irq(), positive IRQ numbers are also taken as error cases. Use "if (irq < 0)" instead of "if (!irq)" to validate the return value of platform_get_irq_byname(). Signed-off-by: Pan Bian --- drivers/power/supply/cpcap-charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c index 11a0763..e4905be 100644 --- a/drivers/power/supply/cpcap-charger.c +++ b/drivers/power/supply/cpcap-charger.c @@ -484,7 +484,7 @@ static int cpcap_usb_init_irq(struct platform_device *pdev, int irq, error; irq = platform_get_irq_byname(pdev, name); - if (!irq) + if (irq < 0) return -ENODEV; error = devm_request_threaded_irq(ddata->dev, irq, NULL,