Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1718489 > unrolled thread

[PATCH][pci-next] PCI: endpoint: fix incorrect end of table check in while loop

Started byColin King <colin.king@canonical.com>
First post2017-08-23 18:10 +0200
Last post2017-08-23 18:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH][pci-next] PCI: endpoint: fix incorrect end of table check in while loop Colin King <colin.king@canonical.com> - 2017-08-23 18:10 +0200

#1718489 — [PATCH][pci-next] PCI: endpoint: fix incorrect end of table check in while loop

FromColin King <colin.king@canonical.com>
Date2017-08-23 18:10 +0200
Subject[PATCH][pci-next] PCI: endpoint: fix incorrect end of table check in while loop
Message-ID<uhGoa-2JU-23@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
---
 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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web