Skip to content
Snippets Groups Projects
Commit d37dfb94 authored by Guy Zana's avatar Guy Zana
Browse files

fix mallocs in if_clone.c

parent d48df277
No related branches found
No related tags found
No related merge requests found
...@@ -109,8 +109,6 @@ VNET_DEFINE(LIST_HEAD(, if_clone), if_cloners); ...@@ -109,8 +109,6 @@ VNET_DEFINE(LIST_HEAD(, if_clone), if_cloners);
#define IFC_IFLIST_REMOVE(_ifc, _ifp) \ #define IFC_IFLIST_REMOVE(_ifc, _ifp) \
LIST_REMOVE(_ifp, if_clones) LIST_REMOVE(_ifp, if_clones)
static MALLOC_DEFINE(M_CLONE, "clone", "interface cloning framework");
void void
vnet_if_clone_init(void) vnet_if_clone_init(void)
{ {
...@@ -291,7 +289,8 @@ if_clone_attach(struct if_clone *ifc) ...@@ -291,7 +289,8 @@ if_clone_attach(struct if_clone *ifc)
len = maxclone >> 3; len = maxclone >> 3;
if ((len << 3) < maxclone) if ((len << 3) < maxclone)
len++; len++;
ifc->ifc_units = malloc(len, M_CLONE, M_WAITOK | M_ZERO); ifc->ifc_units = malloc(len);
bzero(ifc->ifc_units, len);
ifc->ifc_bmlen = len; ifc->ifc_bmlen = len;
IF_CLONE_LOCK_INIT(ifc); IF_CLONE_LOCK_INIT(ifc);
IF_CLONE_ADDREF(ifc); IF_CLONE_ADDREF(ifc);
...@@ -344,7 +343,7 @@ if_clone_free(struct if_clone *ifc) ...@@ -344,7 +343,7 @@ if_clone_free(struct if_clone *ifc)
("%s: ifc_iflist not empty", __func__)); ("%s: ifc_iflist not empty", __func__));
IF_CLONE_LOCK_DESTROY(ifc); IF_CLONE_LOCK_DESTROY(ifc);
free(ifc->ifc_units, M_CLONE); free(ifc->ifc_units);
} }
/* /*
...@@ -373,7 +372,8 @@ if_clone_list(struct if_clonereq *ifcr) ...@@ -373,7 +372,8 @@ if_clone_list(struct if_clonereq *ifcr)
V_if_cloners_count : ifcr->ifcr_count; V_if_cloners_count : ifcr->ifcr_count;
IF_CLONERS_UNLOCK(); IF_CLONERS_UNLOCK();
outbuf = malloc(IFNAMSIZ*buf_count, M_CLONE, M_WAITOK | M_ZERO); outbuf = malloc(IFNAMSIZ*buf_count);
bzero(outbuf, IFNAMSIZ*buf_count);
IF_CLONERS_LOCK(); IF_CLONERS_LOCK();
...@@ -396,7 +396,7 @@ done: ...@@ -396,7 +396,7 @@ done:
if (err == 0) if (err == 0)
err = copyout(outbuf, dst, buf_count*IFNAMSIZ); err = copyout(outbuf, dst, buf_count*IFNAMSIZ);
if (outbuf != NULL) if (outbuf != NULL)
free(outbuf, M_CLONE); free(outbuf);
return (err); return (err);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment