login
Header Space

 
 

[PATCH 16/16][BUG] PCI hotplug core: add missing lock for hotplug slot list (Not for mainline!)

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Alex Chiang <achiang@...>, Greg KH <gregkh@...>
Cc: Gary Hade <garyhade@...>, Kristen Carlson Accardi <kristen.c.accardi@...>, Matthew Wilcox <matthew@...>, <warthog19@...>, <rick.jones2@...>, <linux-kernel@...>, <linux-pci@...>, <linux-acpi@...>
Date: Friday, March 21, 2008 - 12:27 am

Add missing lock for manipulating pci_hotplug_slot_list.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>

---
 drivers/pci/hotplug/pci_hotplug_core.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Index: linux-2.6.25-rc6/drivers/pci/hotplug/pci_hotplug_core.c
===================================================================
--- linux-2.6.25-rc6.orig/drivers/pci/hotplug/pci_hotplug_core.c
+++ linux-2.6.25-rc6/drivers/pci/hotplug/pci_hotplug_core.c
@@ -61,6 +61,7 @@ static int debug;
 //////////////////////////////////////////////////////////////////
 
 static LIST_HEAD(pci_hotplug_slot_list);
+static DEFINE_SPINLOCK(pci_hotplug_slot_list_lock);
 
 /* these strings match up with the values in pci_bus_speed */
 static char *pci_bus_speed_strings[] = {
@@ -529,12 +530,16 @@ static struct hotplug_slot *get_slot_fro
 	struct hotplug_slot *slot;
 	struct list_head *tmp;
 
+	spin_lock(&pci_hotplug_slot_list_lock);
 	list_for_each (tmp, &pci_hotplug_slot_list) {
 		slot = list_entry (tmp, struct hotplug_slot, slot_list);
 		if (strcmp(slot->name, name) == 0)
-			return slot;
+			goto out;
 	}
-	return NULL;
+	slot = NULL;
+out:
+	spin_unlock(&pci_hotplug_slot_list_lock);
+	return slot;
 }
 
 /**
@@ -584,7 +589,9 @@ int pci_hp_register(struct hotplug_slot 
 		}
 	}
 
+	spin_lock(&pci_hotplug_slot_list_lock);
 	list_add(&slot->slot_list, &pci_hotplug_slot_list);
+	spin_unlock(&pci_hotplug_slot_list_lock);
 
 	result = fs_add_slot(pci_slot);
 	kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
@@ -613,7 +620,9 @@ int pci_hp_deregister(struct hotplug_slo
 	if (temp != hotplug)
 		return -ENODEV;
 
+	spin_lock(&pci_hotplug_slot_list_lock);
 	list_del(&hotplug->slot_list);
+	spin_unlock(&pci_hotplug_slot_list_lock);
 
 	slot = hotplug->pci_slot;
 	fs_remove_slot(slot);


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/3, v10] PCI, ACPI: Physical PCI slot objects, Alex Chiang, (Tue Mar 18, 5:05 pm)
Re: [PATCH 0/3, v10] PCI, ACPI: Physical PCI slot objects, Kenji Kaneshige, (Fri Mar 21, 12:07 am)
[PATCH 16/16][BUG] PCI hotplug core: add missing lock for ho..., Kenji Kaneshige, (Fri Mar 21, 12:27 am)
[PATCH 1/3] Construct one fakephp slot per pci slot, Alex Chiang, (Tue Mar 18, 5:08 pm)
[PATCH 2/3] Introduce pci_slot, Alex Chiang, (Tue Mar 18, 5:09 pm)
Re: [PATCH 0/3, v10] PCI, ACPI: Physical PCI slot objects, Matthew Wilcox, (Tue Mar 18, 8:55 pm)
Re: [PATCH 0/3, v10] PCI, ACPI: Physical PCI slot objects, Kenji Kaneshige, (Tue Mar 18, 10:24 pm)
Re: [PATCH 0/3, v10] PCI, ACPI: Physical PCI slot objects, Kenji Kaneshige, (Tue Mar 18, 10:34 pm)
[PATCH 3/3] ACPI PCI slot detection driver, Alex Chiang, (Tue Mar 18, 5:09 pm)
speck-geostationary