mirror of
https://github.com/torvalds/linux.git
synced 2026-10-10 04:18:03 +02:00
net/sched: act_api: avoid non-contiguous action array
In tcf_action_add, when putting the reference for the bound actions it assigns NULLs to just created actions passing a non contiguous array to tcf_action_put_many. Refactor the code so the actions array is always contiguous. Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
3872347e0a
commit
a0e947c9cc
|
|
@ -1135,18 +1135,29 @@ static int tcf_action_put(struct tc_action *p)
|
||||||
return __tcf_action_put(p, false);
|
return __tcf_action_put(p, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put all actions in this array, skip those NULL's. */
|
|
||||||
static void tcf_action_put_many(struct tc_action *actions[])
|
static void tcf_action_put_many(struct tc_action *actions[])
|
||||||
{
|
{
|
||||||
|
struct tc_action *a;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
|
tcf_act_for_each_action(i, a, actions) {
|
||||||
struct tc_action *a = actions[i];
|
const struct tc_action_ops *ops = a->ops;
|
||||||
const struct tc_action_ops *ops;
|
if (tcf_action_put(a))
|
||||||
|
module_put(ops->owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!a)
|
static void tca_put_bound_many(struct tc_action *actions[], int init_res[])
|
||||||
|
{
|
||||||
|
struct tc_action *a;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
tcf_act_for_each_action(i, a, actions) {
|
||||||
|
const struct tc_action_ops *ops = a->ops;
|
||||||
|
|
||||||
|
if (init_res[i] == ACT_P_CREATED)
|
||||||
continue;
|
continue;
|
||||||
ops = a->ops;
|
|
||||||
if (tcf_action_put(a))
|
if (tcf_action_put(a))
|
||||||
module_put(ops->owner);
|
module_put(ops->owner);
|
||||||
}
|
}
|
||||||
|
|
@ -1975,7 +1986,7 @@ static int tcf_action_add(struct net *net, struct nlattr *nla,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
size_t attr_size = 0;
|
size_t attr_size = 0;
|
||||||
int loop, ret, i;
|
int loop, ret;
|
||||||
struct tc_action *actions[TCA_ACT_MAX_PRIO] = {};
|
struct tc_action *actions[TCA_ACT_MAX_PRIO] = {};
|
||||||
int init_res[TCA_ACT_MAX_PRIO] = {};
|
int init_res[TCA_ACT_MAX_PRIO] = {};
|
||||||
|
|
||||||
|
|
@ -1988,13 +1999,11 @@ static int tcf_action_add(struct net *net, struct nlattr *nla,
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = tcf_add_notify(net, n, actions, portid, attr_size, extack);
|
ret = tcf_add_notify(net, n, actions, portid, attr_size, extack);
|
||||||
|
|
||||||
/* only put existing actions */
|
/* only put bound actions */
|
||||||
for (i = 0; i < TCA_ACT_MAX_PRIO; i++)
|
tca_put_bound_many(actions, init_res);
|
||||||
if (init_res[i] == ACT_P_CREATED)
|
|
||||||
actions[i] = NULL;
|
|
||||||
tcf_action_put_many(actions);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user