From 0a9e18d65228376c332d7ec0f87a19b8042e8a43 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 25 Oct 2018 12:24:30 +0200 Subject: [PATCH] libnetlink: don't return error on success Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1602555 Upstream Status: iproute2.git commit b45e300024bb0 commit b45e300024bb0936a41821ad75117dc08b65669f Author: Stephen Hemminger Date: Tue Sep 25 10:08:48 2018 +0200 libnetlink: don't return error on success Change to error handling broke normal code. Fixes: c60389e4f9ea ("libnetlink: fix leak and using unused memory on error") Reported-by: David Ahern Signed-off-by: Stephen Hemminger --- lib/libnetlink.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 5868092..f18dcea 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -666,17 +666,20 @@ static int __rtnl_talk_iov(struct rtnl_handle *rtnl, struct iovec *iov, if (!err->error) /* check messages from kernel */ nl_dump_ext_ack(h, errfn); + else { + errno = -err->error; - if (rtnl->proto != NETLINK_SOCK_DIAG && - show_rtnl_err) - rtnl_talk_error(h, err, errfn); + if (rtnl->proto != NETLINK_SOCK_DIAG && + show_rtnl_err) + rtnl_talk_error(h, err, errfn); + } - errno = -err->error; if (answer) *answer = (struct nlmsghdr *)buf; else free(buf); - return -i; + + return err->error ? -i : 0; } if (answer) { -- 1.8.3.1