Skip to contentSkip to conversation

dock: fix dereference after kfree()

PATCH New Len Brown 1 participant 1 message Apr 7, 2009 ACPI

lore
Share & tools
lore

Len Brown

author reviewer
#0 lore raw

PATCH 1/1 dock: fix dereference after kfree()

From: Dan Carpenter <[email protected]>
Date: Thu, 2 Apr 2009 08:29:56 +0300
Subject: [PATCH] dock: fix dereference after kfree()

upstream f240729832dff3785104d950dad2d3ced4387f6d

dock_remove() calls kfree() on dock_station so we should use list_for_each_entry_safe() to avoid dereferencing freed memory.

Found by smatch (http://repo.or.cz/w/smatch.git/). Compile tested.

---
 drivers/acpi/dock.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/acpi/dock.c +2 -1
index 35094f2..8f62fa0 100644
@@ -1146,9 +1146,10 @@ static int __init dock_init(void)
 static void __exit dock_exit(void)
 {
 	struct dock_station *dock_station;
+	struct dock_station *tmp;
 
 	unregister_acpi_bus_notifier(&dock_acpi_notifier);
-	list_for_each_entry(dock_station, &dock_stations, sibiling)
+	list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibiling)
 		dock_remove(dock_station);
 }
 
Signature · 1 line
1.6.2.2.446.gfbdc