Skip to content

Commit

Permalink
bpf: Fix uninitialized symbol in bpf_perf_link_fill_kprobe()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
laoar authored and Kernel Patches Daemon committed Aug 4, 2023
1 parent 83f304b commit 45022c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/bpf/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -3378,14 +3378,14 @@ static int bpf_perf_link_fill_common(const struct perf_event *event,

if (!ulen ^ !uname)
return -EINVAL;
if (!uname)
return 0;

err = bpf_get_perf_event_info(event, &prog_id, fd_type, &buf,
probe_offset, probe_addr);
if (err)
return err;

if (!uname)
return 0;
if (buf) {
len = strlen(buf);
err = bpf_copy_to_user(uname, buf, ulen, len);
Expand Down

0 comments on commit 45022c4

Please sign in to comment.