summaryrefslogtreecommitdiff
path: root/lib/route/cls/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/route/cls/cgroup.c')
-rw-r--r--lib/route/cls/cgroup.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/route/cls/cgroup.c b/lib/route/cls/cgroup.c
index b1452618..ff993d18 100644
--- a/lib/route/cls/cgroup.c
+++ b/lib/route/cls/cgroup.c
@@ -1,11 +1,5 @@
+/* SPDX-License-Identifier: LGPL-2.1-only */
/*
- * lib/route/cls/cgroup.c Control Groups Classifier
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation version 2.1
- * of the License.
- *
* Copyright (c) 2009-2013 Thomas Graf <tgraf@suug.ch>
*/
@@ -36,17 +30,14 @@ static struct nla_policy cgroup_policy[TCA_CGROUP_MAX+1] = {
static int cgroup_clone(void *_dst, void *_src)
{
- struct rtnl_cgroup *dst = NULL, *src = _src;
+ struct rtnl_cgroup *dst = _dst, *src = _src;
- dst = calloc(1, sizeof(*dst));
- if (!dst)
- return -NLE_NOMEM;
+ dst->cg_ematch = NULL;
- dst->cg_mask = src->cg_mask;
- dst->cg_ematch = rtnl_ematch_tree_clone(src->cg_ematch);
- if (!dst) {
- free(dst);
- return -NLE_NOMEM;
+ if (src->cg_ematch) {
+ dst->cg_ematch = rtnl_ematch_tree_clone(src->cg_ematch);
+ if (!dst->cg_ematch)
+ return -NLE_NOMEM;
}
return 0;