diff mbox series

[net-next,v2,3/4] net/sched: act_api: stop loop over ops array on NULL in tcf_action_init

Message ID 20231201175015.214214-4-pctammela@mojatatu.com (mailing list archive)
State Accepted
Commit e09ac779f736e75eab501b77f2a4f13d245f0a6d
Delegated to: Netdev Maintainers
Headers show
Series net/sched: act_api: contiguous action arrays | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1117 this patch: 1117
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1143 this patch: 1143
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1144 this patch: 1144
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pedro Tammela Dec. 1, 2023, 5:50 p.m. UTC
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>
---
 net/sched/act_api.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Marcelo Ricardo Leitner Dec. 1, 2023, 6:05 p.m. UTC | #1
On Fri, Dec 01, 2023 at 02:50:14PM -0300, Pedro Tammela wrote:
> -	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;

Seems you thought it would have been an abuse to use
tcf_act_for_each_action() here as well, which I can understand.
Marcelo Ricardo Leitner Dec. 1, 2023, 6:10 p.m. UTC | #2
On Fri, Dec 01, 2023 at 10:05:12AM -0800, Marcelo Ricardo Leitner wrote:
> On Fri, Dec 01, 2023 at 02:50:14PM -0300, Pedro Tammela wrote:
> > -	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;
>
> Seems you thought it would have been an abuse to use
> tcf_act_for_each_action() here as well, which I can understand.

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
diff mbox series

Patch

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 2e948e5992b6..d3cb9f5b25da 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -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;
 }