Skip to content

Commit bc2ef0a

Browse files
laoarKernel Patches Daemon
authored and
Kernel Patches Daemon
committed
bpf: Fix uninitialized symbol in bpf_perf_link_fill_kprobe()
The patch 1b715e1: "bpf: Support ->fill_link_info for perf_event" from Jul 9, 2023, leads to the following Smatch static checker warning: kernel/bpf/syscall.c:3416 bpf_perf_link_fill_kprobe() error: uninitialized symbol 'type'. That can happens when uname is NULL. So fix it by verifying the uname when we really need to fill it. Fixes: 1b715e1 ("bpf: Support ->fill_link_info for perf_event") Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/bpf/[email protected]/ Signed-off-by: Yafang Shao <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Jiri Olsa <[email protected]>
1 parent eac4aa7 commit bc2ef0a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/syscall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,14 +3378,14 @@ static int bpf_perf_link_fill_common(const struct perf_event *event,
33783378

33793379
if (!ulen ^ !uname)
33803380
return -EINVAL;
3381-
if (!uname)
3382-
return 0;
33833381

33843382
err = bpf_get_perf_event_info(event, &prog_id, fd_type, &buf,
33853383
probe_offset, probe_addr);
33863384
if (err)
33873385
return err;
33883386

3387+
if (!uname)
3388+
return 0;
33893389
if (buf) {
33903390
len = strlen(buf);
33913391
err = bpf_copy_to_user(uname, buf, ulen, len);

0 commit comments

Comments
 (0)