net/sched: act_api: stop loop over ops array on NULL in tcf_action_init
authorPedro Tammela <pctammela@mojatatu.com>
Fri, 1 Dec 2023 17:50:14 +0000 (14:50 -0300)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 5 Dec 2023 10:15:08 +0000 (11:15 +0100)
The ops array is contiguous, so stop processing whenever a NULL is found

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>
net/sched/act_api.c

index 2e948e5..d3cb9f5 100644 (file)
@@ -1506,10 +1506,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
 err:
        tcf_action_destroy(actions, flags & TCA_ACT_FLAGS_BIND);
 err_mod:
-       for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
-               if (ops[i])
-                       module_put(ops[i]->owner);
-       }
+       for (i = 0; i < TCA_ACT_MAX_PRIO && ops[i]; i++)
+               module_put(ops[i]->owner);
        return err;
 }