From 5c60db874d143bde29212d21b6d2af4da1a43555 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 1 Feb 2016 22:13:45 +0100 Subject: sd-netlink: don't take possesion of netlink fd from caller on failure Fixes: #2338 --- src/libsystemd/sd-netlink/sd-netlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3-54-g00ecf