Re: [PATCH bpf-next v2 2/3] selftests/bpf: allow BTF specs and func infos in test_verifier tests

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

 



> On Tue, 2022-05-31 at 13:52 -0700, Song Liu wrote:

Hi Song,

Thanks a lot for the review, I'll apply the suggested changes and
provide the v3 in one or two days. My only objection is below.

> >  {
> > -       int fd_prog, expected_ret, alignment_prevented_execution;
> > +       int fd_prog, btf_fd, expected_ret, alignment_prevented_execution;
> >         int prog_len, prog_type = test->prog_type;
> >         struct bpf_insn *prog = test->insns;
> >         LIBBPF_OPTS(bpf_prog_load_opts, opts);        __u32 pflags;
> >         int i, err;
> > 
> > +       fd_prog = -1;
> 
> This is not really necessary.

Actually this one is necessary to avoid compiler warning, note the
following fragment of the do_test_single function below:

static void do_test_single(...)
{
        ...
        if (...) {
                btf_fd = load_btf_for_test(...);
                if (btf_fd < 0)
                        goto fail_log;
                opts.prog_btf_fd = btf_fd;
        }
        ...
        fd_prog = bpf_prog_load(..., &opts);
        ...
close_fds:
        ...
        close(fd_prog);
        close(btf_fd);
        ...
        return;
fail_log:
        ...
        goto close_fds;
}

If load_btf_for_test fails the goto fail_log would eventually jump to
close_fds, where fd_prog would be in an uninitialised state.

Best regards,
Eduard




[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