From patchwork Wed Nov 14 21:42:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1000886 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4307RW0R9lz9s55 for ; Wed, 21 Nov 2018 14:32:07 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4307RV602BzF3dG for ; Wed, 21 Nov 2018 14:32:06 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=canonical.com (client-ip=91.189.89.112; helo=youngberry.canonical.com; envelope-from=colin.king@canonical.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42wHzK22bPzF3Jr for ; Thu, 15 Nov 2018 08:42:52 +1100 (AEDT) Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gN2vv-0002uo-Ah; Wed, 14 Nov 2018 21:42:47 +0000 From: Colin King To: Avi Fishman , Tomer Maimon , Patrick Venture , Nancy Yuen , Brendan Higgins , Mark Brown , openbmc@lists.ozlabs.org, linux-spi@vger.kernel.org Subject: [PATCH][next] spi: npcm: fix u32 csgpio being checked for less than zero Date: Wed, 14 Nov 2018 21:42:46 +0000 Message-Id: <20181114214246.15591-1-colin.king@canonical.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 21 Nov 2018 14:31:18 +1100 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" From: Colin Ian King The u32 variable csgpio is being checked for an error return from the call to of_get_named_gpio, however, since this is unsigned this comparison will always be false. Fix this by making csgpio an int and fix up the %u format specifiers to %d accordingly. Detected by CoverityScan, CID#1475476 ("Unsigned compared against 0") Fixes: 2a22f1b30cee ("spi: npcm: add NPCM PSPI controller driver") Signed-off-by: Colin Ian King --- drivers/spi/spi-npcm-pspi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c index 51777515c83f..6dae91091143 100644 --- a/drivers/spi/spi-npcm-pspi.c +++ b/drivers/spi/spi-npcm-pspi.c @@ -329,7 +329,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) unsigned long clk_hz; struct device_node *np = pdev->dev.of_node; int num_cs, i; - u32 csgpio; + int csgpio; int irq; int ret; @@ -417,12 +417,12 @@ static int npcm_pspi_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to get csgpio#%u\n", i); goto out_disable_clk; } - dev_dbg(&pdev->dev, "csgpio#%u = %u\n", i, csgpio); + dev_dbg(&pdev->dev, "csgpio#%u = %d\n", i, csgpio); ret = devm_gpio_request_one(&pdev->dev, csgpio, GPIOF_OUT_INIT_HIGH, DRIVER_NAME); if (ret < 0) { dev_err(&pdev->dev, - "failed to configure csgpio#%u %u\n" + "failed to configure csgpio#%u %d\n" , i, csgpio); goto out_disable_clk; }