Re: [PATCH bpf-next] libbpf: Fix null pointer when using old pref_buffer__new()

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

 



On Thu, Dec 2, 2021 at 2:09 PM Yucong Sun <fallentree@xxxxxx> wrote:
>
> Passing opts point to new function so program using old interface won't
> segfault.
>
> Fixes: 417889346577 ("libbpf: Make perf_buffer__new() use OPTS-based interface")
>
> Signed-off-by: Yucong Sun <fallentree@xxxxxx>
> ---
>  tools/lib/bpf/libbpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 1341ce539662..dac4929e5810 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -10812,7 +10812,7 @@ struct perf_buffer *perf_buffer__new_deprecated(int map_fd, size_t page_cnt,
>                                        opts ? opts->sample_cb : NULL,
>                                        opts ? opts->lost_cb : NULL,
>                                        opts ? opts->ctx : NULL,
> -                                      NULL);
> +                                      opts);

perf_buffer__new_v0_6_0() doesn't need non-null opts, OPTS_VALID(opts,
perf_buffer_opts) handles NULL perfectly fine. After that we never
dereference opts. That NULL there is intentional.

>  }
>
>  DEFAULT_VERSION(perf_buffer__new_raw_v0_6_0, perf_buffer__new_raw, LIBBPF_0.6.0)
> --
> 2.30.2
>



[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