From: Dan Carpenter Date: Thu, 2 Apr 2009 05:29:56 +0000 (+0300) Subject: dock: fix dereference after kfree() X-Git-Tag: 2.1b_release~13268^2~4^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f240729832dff3785104d950dad2d3ced4387f6d;p=platform%2Fkernel%2Fkernel-mfld-blackbay.git dock: fix dereference after kfree() 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. Signed-off-by: Dan Carpenter Signed-off-by: Len Brown --- diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 35094f2..8f62fa0 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -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); }