Skip to content

Commit

Permalink
net_sched: remove cls_flower idr on failure
Browse files Browse the repository at this point in the history
Fixes: c15ab23 ("net/sched: Change cls_flower to use IDR")
Cc: Chris Mi <[email protected]>
Cc: Jiri Pirko <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Acked-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
congwang authored and davem330 committed Sep 21, 2017
1 parent 21f4d5c commit fe2502e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions net/sched/cls_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,28 +922,28 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,

if (!tc_flags_valid(fnew->flags)) {
err = -EINVAL;
goto errout;
goto errout_idr;
}
}

err = fl_set_parms(net, tp, fnew, &mask, base, tb, tca[TCA_RATE], ovr);
if (err)
goto errout;
goto errout_idr;

err = fl_check_assign_mask(head, &mask);
if (err)
goto errout;
goto errout_idr;

if (!tc_skip_sw(fnew->flags)) {
if (!fold && fl_lookup(head, &fnew->mkey)) {
err = -EEXIST;
goto errout;
goto errout_idr;
}

err = rhashtable_insert_fast(&head->ht, &fnew->ht_node,
head->ht_params);
if (err)
goto errout;
goto errout_idr;
}

if (!tc_skip_hw(fnew->flags)) {
Expand All @@ -952,7 +952,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
&mask.key,
fnew);
if (err)
goto errout;
goto errout_idr;
}

if (!tc_in_hw(fnew->flags))
Expand Down Expand Up @@ -981,6 +981,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
kfree(tb);
return 0;

errout_idr:
if (fnew->handle)
idr_remove_ext(&head->handle_idr, fnew->handle);
errout:
tcf_exts_destroy(&fnew->exts);
kfree(fnew);
Expand Down

0 comments on commit fe2502e

Please sign in to comment.