From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932329AbdHWQDG (ORCPT ); Wed, 23 Aug 2017 12:03:06 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:53523 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932118AbdHWQDF (ORCPT ); Wed, 23 Aug 2017 12:03:05 -0400 From: Colin King To: Kishon Vijay Abraham I , Bjorn Helgaas , linux-pci@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][pci-next] PCI: endpoint: fix incorrect end of table check in while loop Date: Wed, 23 Aug 2017 17:03:03 +0100 Message-Id: <20170823160303.23366-1-colin.king@canonical.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently, the while loop will iterate until a matching name is found or until the id pointer wraps around to NULL (the latter is incorrect). The end of a pci_epf_device_id table is terminated with zero'd entries for name and driver_data, so can change the while loop to iterate while the first character in the name is a non-zero character. Detected by CoverityScan, CID#1454557 ("Logically dead code") Fixes: 9e9d6eb48623 ("PCI: endpoint: Add an API to get matching "pci_epf_device_id") Signed-off-by: Colin Ian King --- drivers/pci/endpoint/pci-epf-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index ae6fac5995e3..70eccc04ee7f 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -273,7 +273,7 @@ pci_epf_match_device(const struct pci_epf_device_id *id, struct pci_epf *epf) if (!id || !epf) return NULL; - while (id) { + while (*id->name) { if (strcmp(epf->name, id->name) == 0) return id; id++; -- 2.14.1