Re: [PATCH bpf-next] bpf: Fix an error code in check_btf_func()

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

 



On Wed, Jun 3, 2020 at 10:55 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> This code returns success if kcalloc() but it should return -ENOMEM.
>
> Fixes: 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
>  kernel/bpf/verifier.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 5c7bbaac81ef9..25363f134bf0c 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -7581,8 +7581,10 @@ static int check_btf_func(struct bpf_verifier_env *env,
>         if (!krecord)
>                 return -ENOMEM;
>         info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
> -       if (!info_aux)
> +       if (!info_aux) {
> +               ret = -ENOMEM;
>                 goto err_free;
> +       }

Thanks for the fix.
I think it's better to do 'int ret = -ENOMEM;' instead.



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux