libbpf: Fix null pointer when using old pref_buffer__new()
PATCH 1/1 libbpf: Fix null pointer when using old pref_buffer__new()
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 <[email protected]>
--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -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)
Signature · 1 line
2.30.2
Quoted 16 lines · Yucong Sun
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 <[email protected]>--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0
tools/lib/bpf/libbpf.c struct perf_buffer *perf_buffer__new_deprecated(int map_fd, size_t page_cnt, · line 10815
Quoted 5 lines
tools/lib/bpf/libbpf.c +1
-1@@ -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.
Quoted 6 lines
tools/lib/bpf/libbpf.c +0
-1} DEFAULT_VERSION(perf_buffer__new_raw_v0_6_0, perf_buffer__new_raw, LIBBPF_0.6.0) --2.30.2