summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-01-09 10:44:33 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-01-09 10:44:33 +0000
commit9180d26347953ffda6e1335a6b48bb472a588296 (patch)
treeb7bb576609164793479651a78be9304a1bd84aae
parent3296ab5a25cb84e9c05bd32e3ea515a054a87f33 (diff)
fix leak ether_deatch(): if if_free_sadl() is called before if_detach()
then ifnet_addrs[ifp->if_index] leaks; if it's called after if_detach() then if_free_sadl() does nothing; ok itojun
-rw-r--r--sys/net/if.c15
-rw-r--r--sys/net/if_ethersubr.c5
2 files changed, 15 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 6a4bbdedf65..aab4d9f5d18 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.80 2003/12/31 11:18:25 cedric Exp $ */
+/* $OpenBSD: if.c,v 1.81 2004/01/09 10:44:32 markus Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -327,11 +327,12 @@ if_free_sadl(ifp)
s = splnet();
rtinit(ifa, RTM_DELETE, 0);
+#if 0
TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
-
+ ifnet_addrs[ifp->if_index] = NULL;
+#endif
ifp->if_sadl = NULL;
- ifnet_addrs[ifp->if_index] = NULL;
splx(s);
}
@@ -554,9 +555,15 @@ do { \
TAILQ_REMOVE(&in_ifaddr, (struct in_ifaddr *)ifa,
ia_list);
#endif
+ /* XXX if_free_sadl needs this */
+ if (ifa == ifnet_addrs[ifp->if_index])
+ continue;
+
free(ifa, M_IFADDR);
}
- ifp->if_sadl = NULL;
+ if_free_sadl(ifp);
+
+ free(ifnet_addrs[ifp->if_index], M_IFADDR);
ifnet_addrs[ifp->if_index] = NULL;
free(ifp->if_addrhooks, M_TEMP);
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index e65f22f9d43..04af650715c 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.73 2003/12/10 07:22:42 itojun Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.74 2004/01/09 10:44:32 markus Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -998,7 +998,10 @@ ether_ifdetach(ifp)
free(enm, M_IFMADDR);
}
+#if 0
+ /* moved to if_detach() */
if_free_sadl(ifp);
+#endif
}
#if 0