libnetlink: don't return error on success
Change to error handling broke normal code.
Fixes: c60389e4f9 ("libnetlink: fix leak and using unused memory on error")
Reported-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
5dc2204c01
commit
b45e300024
|
|
@ -666,17 +666,20 @@ static int __rtnl_talk_iov(struct rtnl_handle *rtnl, struct iovec *iov,
|
||||||
if (!err->error)
|
if (!err->error)
|
||||||
/* check messages from kernel */
|
/* check messages from kernel */
|
||||||
nl_dump_ext_ack(h, errfn);
|
nl_dump_ext_ack(h, errfn);
|
||||||
|
else {
|
||||||
|
errno = -err->error;
|
||||||
|
|
||||||
if (rtnl->proto != NETLINK_SOCK_DIAG &&
|
if (rtnl->proto != NETLINK_SOCK_DIAG &&
|
||||||
show_rtnl_err)
|
show_rtnl_err)
|
||||||
rtnl_talk_error(h, err, errfn);
|
rtnl_talk_error(h, err, errfn);
|
||||||
|
}
|
||||||
|
|
||||||
errno = -err->error;
|
|
||||||
if (answer)
|
if (answer)
|
||||||
*answer = (struct nlmsghdr *)buf;
|
*answer = (struct nlmsghdr *)buf;
|
||||||
else
|
else
|
||||||
free(buf);
|
free(buf);
|
||||||
return -i;
|
|
||||||
|
return err->error ? -i : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (answer) {
|
if (answer) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue