Take a reference to make sure that the interface cannot go away during

if_clone_destroy() in case parallel threads try to.

PR:		kern/116837
Submitted by:	Mikolaj Golub (to.my.trociny gmail.com)
MFC after:	10 days
This commit is contained in:
Bjoern A. Zeeb 2010-04-11 18:47:38 +00:00
parent 37ba5a9b14
commit d0088cde62

View File

@ -196,10 +196,11 @@ if_clone_createif(struct if_clone *ifc, char *name, size_t len, caddr_t params)
int int
if_clone_destroy(const char *name) if_clone_destroy(const char *name)
{ {
int err;
struct if_clone *ifc; struct if_clone *ifc;
struct ifnet *ifp; struct ifnet *ifp;
ifp = ifunit(name); ifp = ifunit_ref(name);
if (ifp == NULL) if (ifp == NULL)
return (ENXIO); return (ENXIO);
@ -221,10 +222,14 @@ if_clone_destroy(const char *name)
} }
#endif #endif
IF_CLONERS_UNLOCK(); IF_CLONERS_UNLOCK();
if (ifc == NULL) if (ifc == NULL) {
if_rele(ifp);
return (EINVAL); return (EINVAL);
}
return (if_clone_destroyif(ifc, ifp)); err = if_clone_destroyif(ifc, ifp);
if_rele(ifp);
return err;
} }
/* /*