Skip to content

Commit

Permalink
x25: Do not reference freed memory.
Browse files Browse the repository at this point in the history
In x25_link_free(), we destroy 'nb' before dereferencing
'nb->dev'.  Don't do this, because 'nb' might be freed
by then.

Reported-by: Randy Dunlap <[email protected]>
Tested-by: Randy Dunlap <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Feb 10, 2011
1 parent ebc02e9 commit 96642d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/x25/x25_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ void __exit x25_link_free(void)
write_lock_bh(&x25_neigh_list_lock);

list_for_each_safe(entry, tmp, &x25_neigh_list) {
struct net_device *dev;

nb = list_entry(entry, struct x25_neigh, node);
dev = nb->dev;
__x25_remove_neigh(nb);
dev_put(nb->dev);
dev_put(dev);
}
write_unlock_bh(&x25_neigh_list_lock);
}

0 comments on commit 96642d4

Please sign in to comment.