Blame SOURCES/linuxptp-closesocket.patch
|
|
4693f0 |
commit a3500e14ca4af38034d5ad2115ca7ac271c8c5b4
|
|
|
4693f0 |
Author: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
4693f0 |
Date: Mon Feb 6 15:43:00 2017 +0100
|
|
|
4693f0 |
|
|
|
4693f0 |
Fix leaks of sockets on errors.
|
|
|
4693f0 |
|
|
|
4693f0 |
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
|
|
4693f0 |
|
|
|
4693f0 |
diff --git a/clock.c b/clock.c
|
|
|
4693f0 |
index a6a1a1a..9481606 100644
|
|
|
4693f0 |
--- a/clock.c
|
|
|
4693f0 |
+++ b/clock.c
|
|
|
4693f0 |
@@ -824,11 +824,13 @@ static int clock_add_port(struct clock *c, int phc_index,
|
|
|
4693f0 |
}
|
|
|
4693f0 |
index = sk_interface_index(fd, iface->name);
|
|
|
4693f0 |
if (index < 0) {
|
|
|
4693f0 |
+ close(fd);
|
|
|
4693f0 |
return -1;
|
|
|
4693f0 |
}
|
|
|
4693f0 |
snprintf(key, sizeof(key), "%d", index);
|
|
|
4693f0 |
if (hash_insert(c->index2port, key, p)) {
|
|
|
4693f0 |
pr_err("failed to add port with index %d twice!", index);
|
|
|
4693f0 |
+ close(fd);
|
|
|
4693f0 |
return -1;
|
|
|
4693f0 |
}
|
|
|
4693f0 |
close(fd);
|
|
|
4693f0 |
diff --git a/rtnl.c b/rtnl.c
|
|
|
4693f0 |
index 7f5dc45..251b5f3 100644
|
|
|
4693f0 |
--- a/rtnl.c
|
|
|
4693f0 |
+++ b/rtnl.c
|
|
|
4693f0 |
@@ -160,6 +160,7 @@ int rtnl_open(void)
|
|
|
4693f0 |
}
|
|
|
4693f0 |
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa))) {
|
|
|
4693f0 |
pr_err("failed to bind netlink socket: %m");
|
|
|
4693f0 |
+ close(fd);
|
|
|
4693f0 |
return -1;
|
|
|
4693f0 |
}
|
|
|
4693f0 |
return fd;
|