Mercurial > hg > dhcpcd
changeset 4571:727f73f1ffab draft
dhcpcd: Don't leak resources if we can't find a newly added interface
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Tue, 23 Jul 2019 14:56:49 +0100 |
| parents | 6baf24a8cc49 |
| children | e438211a2b44 |
| files | src/dhcpcd.c |
| diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcpcd.c Tue Jul 23 14:53:01 2019 +0100 +++ b/src/dhcpcd.c Tue Jul 23 14:56:49 2019 +0100 @@ -1001,6 +1001,7 @@ struct if_head *ifs; struct interface *ifp, *iff; const char * const argv[] = { ifname }; + int e; ctx = arg; if (action == -1) { @@ -1024,13 +1025,17 @@ logerr(__func__); return -1; } + ifp = if_find(ifs, ifname); if (ifp == NULL) { /* This can happen if an interface is quickly added * and then removed. */ errno = ENOENT; - return -1; + e = -1; + goto out; } + e = 1; + /* Check if we already have the interface */ iff = if_find(ctx->ifaces, ifp->name); @@ -1059,6 +1064,7 @@ dhcpcd_prestartinterface(iff); } +out: /* Free our discovered list */ while ((ifp = TAILQ_FIRST(ifs))) { TAILQ_REMOVE(ifs, ifp, next); @@ -1066,7 +1072,7 @@ } free(ifs); - return 1; + return e; } static void
