]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
libnetlink: don't return error on success
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 25 Sep 2018 08:08:48 +0000 (10:08 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 25 Sep 2018 08:08:48 +0000 (10:08 +0200)
Change to error handling broke normal code.

Fixes: c60389e4f9ea ("libnetlink: fix leak and using unused memory on error")
Reported-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/libnetlink.c

index 586809292594660be15296010440392bb0dc3ce5..f18dceac2b5e0f7e8a13c92bcdb5b71767946ea1 100644 (file)
@@ -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) {