summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-netlink
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-netlink')
-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;