Re: [PATCH bpf-next v4 04/12] bpf: change return value of verifier function add_subprog()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 25, 2021 at 9:17 PM Yonghong Song <yhs@xxxxxx> wrote:
>
> 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 <yhs@xxxxxx>
> ---

great.

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

>  kernel/bpf/verifier.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 3fc5d1b28b6c..dd860ce1f591 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -1530,7 +1530,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off)
>         }
>         ret = find_subprog(env, off);
>         if (ret >= 0)
> -               return 0;
> +               return ret;
>         if (env->subprog_cnt >= BPF_MAX_SUBPROGS) {
>                 verbose(env, "too many subprograms\n");
>                 return -E2BIG;
> @@ -1538,7 +1538,7 @@ static int add_subprog(struct bpf_verifier_env *env, int off)
>         env->subprog_info[env->subprog_cnt++].start = off;
>         sort(env->subprog_info, env->subprog_cnt,
>              sizeof(env->subprog_info[0]), cmp_subprogs, NULL);
> -       return 0;
> +       return env->subprog_cnt - 1;
>  }
>
>  static int check_subprogs(struct bpf_verifier_env *env)
> --
> 2.24.1
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux