Skip to contentSkip to conversation

acpi: bus: check once more for an empty list after locking it

PATCH New [email protected] 1 participant 1 message Apr 9, 2008 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 acpi: bus: check once more for an empty list after locking it

From: Chuck Ebbert <[email protected]>

List could have become empty after the unlocked check that was made earlier, so check again inside the lock.

Should fix https://bugzilla.redhat.com/show_bug.cgi?id=427765

---

 drivers/acpi/bus.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/acpi/bus.c renamed from drivers/acpi/bus.c~acpi-bus-check-once-more-for-an-empty-list-after-locking-it +4 -3
diff -puN drivers/acpi/bus.c~acpi-bus-check-once-more-for-an-empty-list-after-locking-it drivers/acpi/bus.c
@@ -373,10 +373,11 @@ int acpi_bus_receive_event(struct acpi_b
 	}
 
 	spin_lock_irqsave(&acpi_bus_event_lock, flags);
-	entry =
-	    list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
-	if (entry)
+	if (!list_empty(&acpi_bus_event_list)) {
+		entry = list_entry(acpi_bus_event_list.next,
+				   struct acpi_bus_event, node);
 		list_del(&entry->node);
+	}
 	spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
 
 	if (!entry)

_