Skip to content

Commit e0f557a

Browse files
anakryikogregkh
authored andcommitted
libbpf: don't close(-1) in multi-uprobe feature detector
commit 7d0b395 upstream. Guard close(link_fd) with extra link_fd >= 0 check to prevent close(-1). Detected by Coverity static analysis. Fixes: 04d939a ("libbpf: detect broken PID filtering logic for multi-uprobe") Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20240529231212.768828-1-andrii@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 165634c commit e0f557a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tools/lib/bpf/features.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ static int probe_uprobe_multi_link(int token_fd)
393393
err = -errno; /* close() can clobber errno */
394394

395395
if (link_fd >= 0 || err != -EBADF) {
396-
close(link_fd);
396+
if (link_fd >= 0)
397+
close(link_fd);
397398
close(prog_fd);
398399
return 0;
399400
}

0 commit comments

Comments
 (0)