net_sched: remove cls_flower idr on failure
Subsystems (3)
PATCH 1/1 net_sched: remove cls_flower idr on failure
Fixes c15ab236d69d ("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]>
--- net/sched/cls_flower.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
net/sched/cls_flower.c +9 -6
@@ -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)) {
@@ -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))
@@ -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);
Signature · 1 line
2.13.0
Quoted 4 lines · Wed, Sep 20, 2017 at 06:18:45PM CEST, [email protected] wrote:
Fixes c15ab236d69d ("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]>
Looks fine.
Acked-by Jiri Pirko <[email protected]>
net/sched/cls_flower.c static int fl_change(struct net *net, struct sk_buff *in_skb, · line 986
Quoted 3 lines · Cong Wang
net/sched/cls_flower.c +3
-0+errout_idr: +if (fnew->handle) +idr_remove_ext (&head->handle_idr, fnew->handle);
Hmm, I should check fold instead of fnew->handle here. I will update this patch.
Quoted 7 lines · Cong Wang
net/sched/cls_flower.c static int fl_change(struct net *net, struct sk_buff *in_skb, · line 986
Quoted 3 lines · Cong Wang
net/sched/cls_flower.c +3
-0+errout_idr: +if (fnew->handle) +idr_remove_ext (&head->handle_idr, fnew->handle);Hmm, I should check fold instead of
fnew->handlehere. I will update this patch.
Never mind, it should be the same logic. If fold is non-NULL, then fnew->handle == 0.
It can be applied as it is.
From: Cong Wang <[email protected]>
Date: Wed, 20 Sep 2017 09:18:45 -0700
Quoted 4 lines
Fixes c15ab236d69d ("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]>
Applied, thanks.