Skip to content

Commit d026871

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. Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/bpf/[email protected]/ Signed-off-by: Yafang Shao <[email protected]>
1 parent 390d4c3 commit d026871

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kernel/bpf/syscall.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,16 +3376,16 @@ static int bpf_perf_link_fill_common(const struct perf_event *event,
33763376
size_t len;
33773377
int err;
33783378

3379-
if (!ulen ^ !uname)
3380-
return -EINVAL;
3381-
if (!uname)
3382-
return 0;
3383-
33843379
err = bpf_get_perf_event_info(event, &prog_id, fd_type, &buf,
33853380
probe_offset, probe_addr);
33863381
if (err)
33873382
return err;
33883383

3384+
if (!ulen ^ !uname)
3385+
return -EINVAL;
3386+
if (!uname)
3387+
return 0;
3388+
33893389
if (buf) {
33903390
len = strlen(buf);
33913391
err = bpf_copy_to_user(uname, buf, ulen, len);

0 commit comments

Comments
 (0)