Skip to content

Commit

Permalink
[PATCH] ns558 list handling fix
Browse files Browse the repository at this point in the history
Need to use list_for_entry_safe(), as we're removing items during the
traversal.  list_for_each_entry() uses the first ptr also as an iterator, if
you kfree() it slab takes it, might poison it and then you try to use it to
iterate to the next object in list.

Cc: Vojtech Pavlik <vojtech@suse.cz>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Alexander Nyberg authored and Linus Torvalds committed Aug 10, 2005
1 parent c043817 commit 22d0def
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/input/gameport/ns558.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ static int __init ns558_init(void)

static void __exit ns558_exit(void)
{
struct ns558 *ns558;
struct ns558 *ns558, *safe;

list_for_each_entry(ns558, &ns558_list, node) {
list_for_each_entry_safe(ns558, safe, &ns558_list, node) {
gameport_unregister_port(ns558->gameport);
release_region(ns558->io & ~(ns558->size - 1), ns558->size);
kfree(ns558);
Expand Down

0 comments on commit 22d0def

Please sign in to comment.