diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2021-05-25 12:18:10 (GMT) |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2021-06-16 09:58:33 (GMT) |
commit | 30552e849c38972dd11fafbb8085924987b002cc (patch) | |
tree | a633ba80e8576b2fe201da0fbff76c443b62f793 | |
parent | 764c30a272b452e423740da60eaf7cce75895953 (diff) | |
download | libnl-30552e849c38972dd11fafbb8085924987b002cc.zip libnl-30552e849c38972dd11fafbb8085924987b002cc.tar.gz libnl-30552e849c38972dd11fafbb8085924987b002cc.tar.bz2 |
route/cls: fix cgroup's clone() function
The destination object doesn't have to be allocated because it's
passed as _dst argument. Also, the function doesn't have to copy plain
fields.
-rw-r--r-- | lib/route/cls/cgroup.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/route/cls/cgroup.c b/lib/route/cls/cgroup.c index 1c5a45c..ba72fe2 100644 --- a/lib/route/cls/cgroup.c +++ b/lib/route/cls/cgroup.c @@ -30,17 +30,12 @@ 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_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; |