mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
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>
This commit is contained in:
parent
f2fbdacbf8
commit
3932d76033
1 changed files with 15 additions and 6 deletions
|
|
@ -443,21 +443,30 @@ ifc_alloc_unit(struct if_clone *ifc, int *unit)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue