Skip to content

Commit

Permalink
dock: fix dereference after kfree()
Browse files Browse the repository at this point in the history
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 <error27@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Dan Carpenter authored and Len Brown committed Apr 3, 2009
1 parent 5b4c0b6 commit f240729
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/acpi/dock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit f240729

Please sign in to comment.