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[])
 {
+       struct tc_action *a;
        int i;
 
-       for (i = 0; i < TCA_ACT_MAX_PRIO; i++) {
-               struct tc_action *a = actions[i];
-               const struct tc_action_ops *ops;
+       tcf_act_for_each_action(i, a, actions) {
+               const struct tc_action_ops *ops = a->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;
-               ops = a->ops;
+
                if (tcf_action_put(a))
                        module_put(ops->owner);
        }
                          struct netlink_ext_ack *extack)
 {
        size_t attr_size = 0;
-       int loop, ret, i;
+       int loop, ret;
        struct tc_action *actions[TCA_ACT_MAX_PRIO] = {};
        int init_res[TCA_ACT_MAX_PRIO] = {};
 
 
        if (ret < 0)
                return ret;
+
        ret = tcf_add_notify(net, n, actions, portid, attr_size, extack);
 
-       /* only put existing actions */
-       for (i = 0; i < TCA_ACT_MAX_PRIO; i++)
-               if (init_res[i] == ACT_P_CREATED)
-                       actions[i] = NULL;
-       tcf_action_put_many(actions);
+       /* only put bound actions */
+       tca_put_bound_many(actions, init_res);
 
        return ret;
 }