]> granicus.if.org Git - libnl/commitdiff
route: make rtnl_tc_clone() more robust against NLE_NOMEM
authorThomas Haller <thaller@redhat.com>
Mon, 24 Nov 2014 16:19:54 +0000 (17:19 +0100)
committerThomas Haller <thaller@redhat.com>
Mon, 24 Nov 2014 17:21:59 +0000 (18:21 +0100)
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>
lib/route/tc.c

index 4c928226139c140ecc0aa22eb77cfdbbf5b6df85..1dcb9865954e5b1e11c00ffe4a62eced51de8c3d 100644 (file)
@@ -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) {