summaryrefslogtreecommitdiffstats
path: root/lib/route/tc.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-11-24 16:19:54 (GMT)
committerThomas Haller <thaller@redhat.com>2014-11-24 17:21:59 (GMT)
commit703989eb12185471d6e494105f91470ea74d822d (patch)
treeed7e0ec77eb1247238a3667a2512f9d933f1312c /lib/route/tc.c
parent24ad51518f5678d83423e7f446751d8a3c1961c2 (diff)
downloadlibnl-703989eb12185471d6e494105f91470ea74d822d.zip
libnl-703989eb12185471d6e494105f91470ea74d822d.tar.gz
libnl-703989eb12185471d6e494105f91470ea74d822d.tar.bz2
route: make rtnl_tc_clone() more robust against NLE_NOMEM
When oo_clone() fails, the new object is freed. Make sure 'dst' does not own parts of 'src'. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route/tc.c')
-rw-r--r--lib/route/tc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/route/tc.c b/lib/route/tc.c
index 4c92822..1dcb986 100644
--- a/lib/route/tc.c
+++ b/lib/route/tc.c
@@ -760,16 +760,24 @@ int rtnl_tc_clone(struct nl_object *dstobj, struct nl_object *srcobj)
dst->tc_link = src->tc_link;
}
+ dst->tc_opts = NULL;
+ dst->tc_xstats = NULL;
+ dst->tc_subdata = NULL;
+ dst->ce_mask &= ~(TCA_ATTR_OPTS |
+ TCA_ATTR_XSTATS);
+
if (src->tc_opts) {
dst->tc_opts = nl_data_clone(src->tc_opts);
if (!dst->tc_opts)
return -NLE_NOMEM;
+ dst->ce_mask |= TCA_ATTR_OPTS;
}
-
+
if (src->tc_xstats) {
dst->tc_xstats = nl_data_clone(src->tc_xstats);
if (!dst->tc_xstats)
return -NLE_NOMEM;
+ dst->ce_mask |= TCA_ATTR_XSTATS;
}
if (src->tc_subdata) {