summaryrefslogtreecommitdiffstats
path: root/src/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-07-23 14:56:49 +0100
committerRoy Marples <roy@marples.name>2019-07-23 14:56:49 +0100
commitab0d18db3be7f3e9509365dbda8639c3d7163cd7 (patch)
tree858551325d3a785f3a2f9345f355f02879f32426 /src/dhcpcd.c
parent05ba1d2542f080f492dcc239bf60ad3c07472245 (diff)
downloaddhcpcd-ab0d18db3be7f3e9509365dbda8639c3d7163cd7.tar.xz
dhcpcd: Don't leak resources if we can't find a newly added interface
Diffstat (limited to 'src/dhcpcd.c')
-rw-r--r--src/dhcpcd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c
index 3584d223..cd0b0df1 100644
--- a/src/dhcpcd.c
+++ b/src/dhcpcd.c
@@ -1001,6 +1001,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname)
struct if_head *ifs;
struct interface *ifp, *iff;
const char * const argv[] = { ifname };
+ int e;
ctx = arg;
if (action == -1) {
@@ -1024,13 +1025,17 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname)
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_handleinterface(void *arg, int action, const char *ifname)
dhcpcd_prestartinterface(iff);
}
+out:
/* Free our discovered list */
while ((ifp = TAILQ_FIRST(ifs))) {
TAILQ_REMOVE(ifs, ifp, next);
@@ -1066,7 +1072,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname)
}
free(ifs);
- return 1;
+ return e;
}
static void