From patchwork Wed Aug 21 12:01:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1150800 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46D5qK3HCCz9sBF for ; Wed, 21 Aug 2019 22:01:33 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727136AbfHUMB2 (ORCPT ); Wed, 21 Aug 2019 08:01:28 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:51807 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726372AbfHUMB2 (ORCPT ); Wed, 21 Aug 2019 08:01:28 -0400 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 1i0PIq-0006W5-Lf; Wed, 21 Aug 2019 12:01:25 +0000 From: Colin King To: Vidya Sagar , Lorenzo Pieralisi , Bjorn Helgaas , Thierry Reding , Jonathan Hunter , linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] PCI: tegra: tegra194: fix phy_count less than zero check Date: Wed, 21 Aug 2019 13:01:23 +0100 Message-Id: <20190821120123.14223-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Colin Ian King The check for pcie->phy_count < 0 is always false because phy_count is an unsigned int and can never be less than zero. Fix this by assigning ret to the return from of_property_count_strings and checking if this is less than zero instead. Addresses-Coverity: ("Dead code") Fixes: 6404441c8e13 ("PCI: tegra: Add Tegra194 PCIe support") Signed-off-by: Colin Ian King Acked-by: Thierry Reding --- drivers/pci/controller/dwc/pcie-tegra194.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c index fc0dbeb31d78..b47ea3e68303 100644 --- a/drivers/pci/controller/dwc/pcie-tegra194.c +++ b/drivers/pci/controller/dwc/pcie-tegra194.c @@ -969,12 +969,13 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie) return ret; } - pcie->phy_count = of_property_count_strings(np, "phy-names"); - if (pcie->phy_count < 0) { + ret = of_property_count_strings(np, "phy-names"); + if (ret < 0) { dev_err(pcie->dev, "Failed to find PHY entries: %d\n", - pcie->phy_count); - return pcie->phy_count; + ret); + return ret; } + pcie->phy_count = ret; if (of_property_read_bool(np, "nvidia,update-fc-fixup")) pcie->update_fc_fixup = true;