Date: Thu, 30 Aug 2012 12:18:46 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r239905 - head/sys/net Message-ID: <201208301218.q7UCIkBT039181@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Thu Aug 30 12:18:45 2012 New Revision: 239905 URL: http://svn.freebsd.org/changeset/base/239905 Log: In ifc_alloc_unit(): - In the !wildcard case, return ENOSPC instead of confusing EEXIST in case if ifc->ifc_maxunit reached. - Fix unit leak, that I've introduced in previous revision. Submitted by: Daan Vreeken <Daan vitsch.nl> Modified: head/sys/net/if_clone.c Modified: head/sys/net/if_clone.c ============================================================================== --- head/sys/net/if_clone.c Thu Aug 30 11:52:26 2012 (r239904) +++ head/sys/net/if_clone.c Thu Aug 30 12:18:45 2012 (r239905) @@ -443,21 +443,30 @@ ifc_alloc_unit(struct if_clone *ifc, int wildcard = (*unit < 0); retry: - if (wildcard) { + if (*unit > ifc->ifc_maxunit) + return (ENOSPC); + if (*unit < 0) { *unit = alloc_unr(ifc->ifc_unrhdr); if (*unit == -1) return (ENOSPC); } else { *unit = alloc_unr_specific(ifc->ifc_unrhdr, *unit); - if (*unit == -1) - return (EEXIST); + if (*unit == -1) { + if (wildcard) { + (*unit)++; + goto retry; + } else + return (EEXIST); + } } snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, *unit); if (ifunit(name) != NULL) { - if (wildcard) - goto retry; /* XXXGL: yep, it's a unit leak */ - else + free_unr(ifc->ifc_unrhdr, *unit); + if (wildcard) { + (*unit)++; + goto retry; + } else return (EEXIST); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208301218.q7UCIkBT039181>