Fix leaks of sockets on errors.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
73318c5b99
commit
8deb52a849
2
clock.c
2
clock.c
|
@ -830,11 +830,13 @@ static int clock_add_port(struct clock *c, int phc_index,
|
||||||
}
|
}
|
||||||
index = sk_interface_index(fd, iface->name);
|
index = sk_interface_index(fd, iface->name);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprintf(key, sizeof(key), "%d", index);
|
snprintf(key, sizeof(key), "%d", index);
|
||||||
if (hash_insert(c->index2port, key, p)) {
|
if (hash_insert(c->index2port, key, p)) {
|
||||||
pr_err("failed to add port with index %d twice!", index);
|
pr_err("failed to add port with index %d twice!", index);
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
1
rtnl.c
1
rtnl.c
|
@ -160,6 +160,7 @@ int rtnl_open(void)
|
||||||
}
|
}
|
||||||
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa))) {
|
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa))) {
|
||||||
pr_err("failed to bind netlink socket: %m");
|
pr_err("failed to bind netlink socket: %m");
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
|
|
Loading…
Reference in New Issue