Skip to content

Commit cadb9c9

Browse files
yotamgidavem330
authored andcommitted
net/sched: act_sample: Fix error path in init
Fix error path of in sample init, by releasing the tc hash in case of failure in psample_group creation. Fixes: 5c5670f ("net/sched: Introduce sample tc action") Reported-by: Cong Wang <xiyou.wangcong@gmail.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Yotam Gigi <yotamg@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6107dbd commit cadb9c9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/sched/act_sample.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,
8181
s->rate = nla_get_u32(tb[TCA_SAMPLE_RATE]);
8282
s->psample_group_num = nla_get_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]);
8383
psample_group = psample_group_get(net, s->psample_group_num);
84-
if (!psample_group)
84+
if (!psample_group) {
85+
if (ret == ACT_P_CREATED)
86+
tcf_hash_release(*a, bind);
8587
return -ENOMEM;
88+
}
8689
RCU_INIT_POINTER(s->psample_group, psample_group);
8790

8891
if (tb[TCA_SAMPLE_TRUNC_SIZE]) {

0 commit comments

Comments
 (0)