From owner-svn-src-all@FreeBSD.ORG Thu Aug 30 12:18:46 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7059D106566C; Thu, 30 Aug 2012 12:18:46 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5B39A8FC0A; Thu, 30 Aug 2012 12:18:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7UCIkCr039183; Thu, 30 Aug 2012 12:18:46 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7UCIkBT039181; Thu, 30 Aug 2012 12:18:46 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201208301218.q7UCIkBT039181@svn.freebsd.org> From: Gleb Smirnoff Date: Thu, 30 Aug 2012 12:18:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239905 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Aug 2012 12:18:46 -0000 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 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); }