From 3395dd6eb8f69fd45aec7238eba75476f2eb050c Mon Sep 17 00:00:00 2001 From: Alexander Kabaev Date: Sat, 23 Dec 2017 16:23:58 +0000 Subject: [PATCH] Do not double free the memory in if_clone. if_clone_attach function will drop the reference on failure which will free the if_clone structure. No need to do it second time. Reviewed by: glebius, ae Differential Revision: https://reviews.freebsd.org/D10386 --- sys/net/if_clone.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sys/net/if_clone.c b/sys/net/if_clone.c index dbb7bd6d28a..c455357cae8 100644 --- a/sys/net/if_clone.c +++ b/sys/net/if_clone.c @@ -387,10 +387,8 @@ if_clone_advanced(const char *name, u_int maxunit, ifc_match_t match, ifc->ifc_create = create; ifc->ifc_destroy = destroy; - if (if_clone_attach(ifc) != 0) { - if_clone_free(ifc); + if (if_clone_attach(ifc) != 0) return (NULL); - } EVENTHANDLER_INVOKE(if_clone_event, ifc); @@ -410,10 +408,8 @@ if_clone_simple(const char *name, ifcs_create_t create, ifcs_destroy_t destroy, ifc->ifcs_destroy = destroy; ifc->ifcs_minifs = minifs; - if (if_clone_attach(ifc) != 0) { - if_clone_free(ifc); + if (if_clone_attach(ifc) != 0) return (NULL); - } for (unit = 0; unit < minifs; unit++) { char name[IFNAMSIZ];