]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lib: bpf_legacy: treat 0 as a valid file descriptor
authorAndrea Claudi <aclaudi@redhat.com>
Mon, 19 Apr 2021 13:49:56 +0000 (15:49 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 27 Apr 2021 04:05:19 +0000 (21:05 -0700)
As stated in the man page(), open returns a non-negative integer as a
file descriptor. Hence, when checking for its return value to be ok, we
should include 0 as a valid value.

This fixes a covscan warning about a missing close() in this function.

Fixes: ecb05c0f997d ("bpf: improve error reporting around tail calls")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/bpf_legacy.c

index 8a03b9c2ad37ce42e2f588c3221bd5464c2f8371..7ff10e4f2a966aa2e339cddb399cef997b96d8de 100644 (file)
@@ -2832,7 +2832,7 @@ static void bpf_get_cfg(struct bpf_elf_ctx *ctx)
        int fd;
 
        fd = open(path_jit, O_RDONLY);
-       if (fd > 0) {
+       if (fd >= 0) {
                char tmp[16] = {};
 
                if (read(fd, tmp, sizeof(tmp)) > 0)