From: David S. Miller Date: Thu, 10 Feb 2011 05:48:36 +0000 (-0800) Subject: x25: Do not reference freed memory. X-Git-Tag: MMI-PSA29.97-13-9~20736^2~35 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=96642d42f076101ba98866363d908cab706d156c;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git x25: Do not reference freed memory. 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 Tested-by: Randy Dunlap Signed-off-by: David S. Miller --- diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c index 4cbc942f762a..21306928d47f 100644 --- a/net/x25/x25_link.c +++ b/net/x25/x25_link.c @@ -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); }