]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x25: Do not reference freed memory.
authorDavid S. Miller <davem@davemloft.net>
Thu, 10 Feb 2011 05:48:36 +0000 (21:48 -0800)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Sun, 17 Apr 2011 20:16:15 +0000 (16:16 -0400)
commit 96642d42f076101ba98866363d908cab706d156c 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: Paul Gortmaker <paul.gortmaker@windriver.com>
net/x25/x25_link.c

index b25c6463c3e996cf536454603f4f0257f3b8b51c..88048b6b0b2bd5e65e08d4c3e07c266995ca7d4c 100644 (file)
@@ -392,9 +392,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);
 }