From patchwork Sun Nov 12 16:01:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pan Bian X-Patchwork-Id: 10054829 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 99235602A7 for ; Sun, 12 Nov 2017 16:02:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D57129153 for ; Sun, 12 Nov 2017 16:02:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ED552919C; Sun, 12 Nov 2017 16:02:06 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 D9A5229153 for ; Sun, 12 Nov 2017 16:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751418AbdKLQCE (ORCPT ); Sun, 12 Nov 2017 11:02:04 -0500 Received: from m12-13.163.com ([220.181.12.13]:43365 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751249AbdKLQCD (ORCPT ); Sun, 12 Nov 2017 11:02:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=i0EISzrYupQeprrRdR K32cuVSyTUclUDnCcKoXa+K+Y=; b=EozfQ6PZ7XvIBV0fo4W9NnwM3tzD4d0Ut+ VI+haqape/EZI0cLpCKMir91zHOwTBRpbbnxwa1zJxbeixvdG9PIXBaPl3xsYbxf HkGFQSz550Cc0oItdKKYUSqgVF19As82FOqvy194y+InJ2EbihgSzUO+eR/TwiLI Bg3U9KDJI= Received: from localhost.localdomain (unknown [106.120.213.14]) by smtp9 (Coremail) with SMTP id DcCowADXjl5ccAha7XvwQA--.19879S3; Mon, 13 Nov 2017 00:01:36 +0800 (CST) From: Pan Bian To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Tony Lindgren , Sebastian Reichel , Rob Herring Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] iio: adc: cpcap: fix incorrect validation Date: Mon, 13 Nov 2017 00:01:20 +0800 Message-Id: <1510502480-27117-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DcCowADXjl5ccAha7XvwQA--.19879S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xw4DuryfWF48tFyUGrykXwb_yoWDXFc_uw 42gwsrJrs7AFs0vw4Utr4fZFyvkF97JF1kZa4ktFy3u3sxGas3Kw10vF4rXFs7Ww1jqa4U urn5uFZ3C3y3AjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8czVUUUUUU== X-Originating-IP: [106.120.213.14] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQA+OclSIT6qCCgADsB Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@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_adc_probe(), positive IRQ numbers are also taken as error cases. Use "if (ddata->irq < 0)" instead of "if (!ddata->irq)" to validate the return value of platform_get_irq_byname(). Signed-off-by: Pan Bian Reviewed-by: Sebastian Reichel Acked-by: Tony Lindgren --- drivers/iio/adc/cpcap-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c index 6e419d5..f153e026 100644 --- a/drivers/iio/adc/cpcap-adc.c +++ b/drivers/iio/adc/cpcap-adc.c @@ -1012,7 +1012,7 @@ static int cpcap_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); ddata->irq = platform_get_irq_byname(pdev, "adcdone"); - if (!ddata->irq) + if (ddata->irq < 0) return -ENODEV; error = devm_request_threaded_irq(&pdev->dev, ddata->irq, NULL,