summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-01 22:13:45 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-01 22:18:16 +0100
commit5c60db874d143bde29212d21b6d2af4da1a43555 (patch)
treeaaba3389611237603902d6a526226e857bf75bef /src
parentfabab19068b6ccb894b0d2a6efbe0ad580771d05 (diff)
sd-netlink: don't take possesion of netlink fd from caller on failure
Fixes: #2338
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
index 15d387df2c..ab42b96a2e 100644
--- a/src/libsystemd/sd-netlink/sd-netlink.c
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
@@ -118,8 +118,10 @@ int sd_netlink_open_fd(sd_netlink **ret, int fd) {
rtnl->fd = fd;
r = socket_bind(rtnl);
- if (r < 0)
+ if (r < 0) {
+ rtnl->fd = -1; /* on failure, the caller remains owner of the fd, hence don't close it here */
return r;
+ }
*ret = rtnl;
rtnl = NULL;