Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 798

kernel-2.6.18-238.el5.src.rpm

From: Mauro Carvalho Chehab <mchehab@redhat.com>
Date: Tue, 23 Nov 2010 17:34:07 -0500
Subject: [edac] i7core_edac: properly terminate pci_dev_table
Message-id: <20101123153407.463f006e@pedra>
Patchwork-id: 29584
O-Subject: [PATCH RHEL5 28/29] BZ#:651869 i7core_edac: properly terminate
	pci_dev_table
Bugzilla: 651869
RH-Acked-by: Aristeu Rozanski <aris@redhat.com>

Changeset: 3c52cc57ccd5c99441368d5e66be36681ce90e72

At pci_xeon_fixup(), it waits for a null-terminated table, while at
i7core_get_all_devices, it just do a for 0..ARRAY_SIZE. As other tables
are zero-terminated, change it to be terminate with 0 as well, and fixes
a bug where it may be running out of the table elements.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>

diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 9561551..f8642c8 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -350,6 +350,7 @@ static const struct pci_id_table pci_dev_table[] = {
 	PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem),
 	PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield),
 	PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere),
+	{0,}			/* 0 terminated list. */
 };
 
 /*
@@ -1410,14 +1411,13 @@ static int i7core_get_onedevice(struct pci_dev **prev,
 
 static int i7core_get_all_devices(void)
 {
-	int i, j, rc, last_bus;
+	int i, rc, last_bus;
 	struct pci_dev *pdev = NULL;
-	const struct pci_id_table *table;
+	const struct pci_id_table *table = pci_dev_table;
 
 	last_bus = i7core_pci_lastbus();
 
-	for (j = 0; j < ARRAY_SIZE(pci_dev_table); j++) {
-		table = &pci_dev_table[j];
+	while (table && table->descr) {
 		for (i = 0; i < table->n_devs; i++) {
 			pdev = NULL;
 			do {
@@ -1433,6 +1433,7 @@ static int i7core_get_all_devices(void)
 				}
 			} while (pdev);
 		}
+		table++;
 	}
 
 	return 0;