Skip to content

Commit

Permalink
x25: Do not reference freed memory.
Browse files Browse the repository at this point in the history
commit 96642d4 upstream.

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 <randy.dunlap@oracle.com>
Tested-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
David S. Miller authored and Greg Kroah-Hartman committed Mar 2, 2011
1 parent cbc0238 commit 7599b39
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 @@ -391,9 +391,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 7599b39

Please sign in to comment.