From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751435AbdH1SZJ (ORCPT ); Mon, 28 Aug 2017 14:25:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:37102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbdH1SZH (ORCPT ); Mon, 28 Aug 2017 14:25:07 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB12621A2F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Mon, 28 Aug 2017 13:25:05 -0500 From: Bjorn Helgaas To: Colin King Cc: Kishon Vijay Abraham I , Bjorn Helgaas , linux-pci@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][pci-next] PCI: endpoint: fix incorrect end of table check in while loop Message-ID: <20170828182505.GH8154@bhelgaas-glaptop.roam.corp.google.com> References: <20170823160303.23366-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170823160303.23366-1-colin.king@canonical.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 23, 2017 at 05:03:03PM +0100, Colin King wrote: > 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 Kishon, do you want to ack this, please? > --- > 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 >