diff options
author | Thomas Haller <thaller@redhat.com> | 2018-10-08 13:41:25 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-10-08 13:41:25 +0200 |
commit | 52cd3c14ce42db53637f8f5dafaf0d5c24d724db (patch) | |
tree | 8b1fb2be30555efb5c20048eef7a3d3f738a3861 /lib | |
parent | 4702d536796715f2ee001565d3d48d69276726e4 (diff) | |
download | libnl-52cd3c14ce42db53637f8f5dafaf0d5c24d724db.tar.gz |
lib/tc: ensure correct error code in rtnl_tc_msg_build()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/route/tc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/route/tc.c b/lib/route/tc.c index 62efd354..061e54e1 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -202,14 +202,16 @@ int rtnl_tc_msg_build(struct rtnl_tc *tc, int type, int flags, .tcm_handle = tc->tc_handle, .tcm_parent = tc->tc_parent, }; - int err = -NLE_MSGSIZE; + int err; msg = nlmsg_alloc_simple(type, flags); if (!msg) return -NLE_NOMEM; - if (nlmsg_append(msg, &tchdr, sizeof(tchdr), NLMSG_ALIGNTO) < 0) + if (nlmsg_append(msg, &tchdr, sizeof(tchdr), NLMSG_ALIGNTO) < 0) { + err = -NLE_MSGSIZE; goto nla_put_failure; + } if (tc->ce_mask & TCA_ATTR_KIND) NLA_PUT_STRING(msg, TCA_KIND, tc->tc_kind); @@ -220,8 +222,10 @@ int rtnl_tc_msg_build(struct rtnl_tc *tc, int type, int flags, void *data = rtnl_tc_data(tc); if (ops->to_msg_fill) { - if (!(opts = nla_nest_start(msg, TCA_OPTIONS))) + if (!(opts = nla_nest_start(msg, TCA_OPTIONS))) { + err = -NLE_NOMEM; goto nla_put_failure; + } if ((err = ops->to_msg_fill(tc, data, msg)) < 0) goto nla_put_failure; |