Skip to content

Commit 282a0f4

Browse files
yonghong-songAlexei Starovoitov
authored andcommitted
bpf: Change return value of verifier function add_subprog()
Currently, verifier function add_subprog() returns 0 for success and negative value for failure. Change the return value to be the subprog number for success. This functionality will be used in the next patch to save a call to find_subprog(). Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 1435137 commit 282a0f4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/verifier.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,15 +1530,15 @@ static int add_subprog(struct bpf_verifier_env *env, int off)
15301530
}
15311531
ret = find_subprog(env, off);
15321532
if (ret >= 0)
1533-
return 0;
1533+
return ret;
15341534
if (env->subprog_cnt >= BPF_MAX_SUBPROGS) {
15351535
verbose(env, "too many subprograms\n");
15361536
return -E2BIG;
15371537
}
15381538
env->subprog_info[env->subprog_cnt++].start = off;
15391539
sort(env->subprog_info, env->subprog_cnt,
15401540
sizeof(env->subprog_info[0]), cmp_subprogs, NULL);
1541-
return 0;
1541+
return env->subprog_cnt - 1;
15421542
}
15431543

15441544
static int check_subprogs(struct bpf_verifier_env *env)

0 commit comments

Comments
 (0)