From: Amerigo Wang <amwang@redhat.com> Date: Thu, 27 May 2010 08:24:09 -0400 Subject: [net] ipv6: fix more memory leaks when ndisc_init fails Message-id: <20100527082810.6019.49168.sendpatchset@localhost.localdomain> Patchwork-id: 25824 O-Subject: [PATCH RHEL5] route6/fib6: fix more memory leaks when ndisc_init() fails Bugzilla: 555338 RH-Acked-by: Jiri Pirko <jpirko@redhat.com> RH-Acked-by: David S. Miller <davem@redhat.com> BZ: https://bugzilla.redhat.com/show_bug.cgi?id=555338 Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=2475236 Description: This is a direct backport of the following two commits: commit 36f73d0c3b7efa72cd8b89f2d429ff39bc12f15c Author: Dmitry Mishin <dim@openvz.org> Date: Fri Nov 3 16:08:19 2006 -0800 [IPV6]: Add ndisc_netdev_notifier unregister. If inet6_init() fails later than ndisc_init() call, or IPv6 module is unloaded, ndisc_netdev_notifier call remains in the list and will follows in oops later. commit bfb85c9f753a7172bd962e8717118191dfd612cc Author: Randy Dunlap <randy.dunlap@oracle.com> Date: Sun Oct 21 16:24:27 2007 -0700 [ATM]: Fix clip module reload crash. net/atm/clip.c crashes the kernel if it (module) is loaded, removed, and then loaded again. Its exit call to neigh_table_clear() should destroy the cache after freeing it. Signed-off-by: WANG Cong <amwang@redhat.com> diff --git a/net/core/neighbour.c b/net/core/neighbour.c index d720d05..8bc1538 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1445,6 +1445,9 @@ int neigh_table_clear(struct neigh_table *tbl) free_percpu(tbl->stats); tbl->stats = NULL; + kmem_cache_destroy(tbl->kmem_cachep); + tbl->kmem_cachep = NULL; + return 0; } diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 1bfc483..22be73f 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1894,6 +1894,7 @@ int __init ndisc_init(struct net_proto_family *ops) void ndisc_cleanup(void) { + unregister_netdevice_notifier(&ndisc_netdev_notifier); #ifdef CONFIG_SYSCTL neigh_sysctl_unregister(&nd_tbl.parms); #endif