Message ID | 20211202220933.1155174-1-fallentree@fb.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next] libbpf: Fix null pointer when using old pref_buffer__new() | expand |
On Thu, Dec 2, 2021 at 2:09 PM Yucong Sun <fallentree@fb.com> 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@fb.com> > --- > 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 >
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); } DEFAULT_VERSION(perf_buffer__new_raw_v0_6_0, perf_buffer__new_raw, LIBBPF_0.6.0)
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@fb.com> --- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)