summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2008-04-19 22:04:51 +0000
committerbrooks <brooks@FreeBSD.org>2008-04-19 22:04:51 +0000
commitbf4b91bf6ad2d2958ae7597f7428fcb04f8ef393 (patch)
treeb67ece9c74076830861eede172d7ab8375354a7a
parentc7094ab9ab7051337a2de22c0e040b81156fc7e3 (diff)
downloadFreeBSD-src-bf4b91bf6ad2d2958ae7597f7428fcb04f8ef393.zip
FreeBSD-src-bf4b91bf6ad2d2958ae7597f7428fcb04f8ef393.tar.gz
Delay the global registration of the struct ifnet in if_alloc() until after
we're certain the allocation will entierly succeed. This fixes a leak in a fairly unlikely case. Reported by: vijay singh <vijjus at rocketmail dot com> MFC after: 1 week
-rw-r--r--sys/net/if.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 8929c19..c3c367b 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -377,7 +377,6 @@ if_alloc(u_char type)
if_index = ifp->if_index;
if (if_index >= if_indexlim)
if_grow();
- ifnet_byindex(ifp->if_index) = ifp;
ifp->if_type = type;
@@ -388,6 +387,7 @@ if_alloc(u_char type)
return (NULL);
}
}
+ ifnet_byindex(ifp->if_index) = ifp;
IF_ADDR_LOCK_INIT(ifp);
return (ifp);
OpenPOWER on IntegriCloud