]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
selftests/bpf: Fix error return code in run_getsockopt_test()
authorWang Hai <wanghai38@huawei.com>
Mon, 16 Nov 2020 10:16:33 +0000 (18:16 +0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 16 Nov 2020 21:19:07 +0000 (22:19 +0100)
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 65b4414a05eb ("selftests/bpf: add sockopt test that exercises BPF_F_ALLOW_MULTI")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20201116101633.64627-1-wanghai38@huawei.com
tools/testing/selftests/bpf/prog_tests/sockopt_multi.c

index 29188d6f5c8def2623172fd140fa3b3b27d405f5..51fac975b3163fd9491fd66210229cea15432f1d 100644 (file)
@@ -138,7 +138,8 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent,
         */
 
        buf = 0x40;
-       if (setsockopt(sock_fd, SOL_IP, IP_TOS, &buf, 1) < 0) {
+       err = setsockopt(sock_fd, SOL_IP, IP_TOS, &buf, 1);
+       if (err < 0) {
                log_err("Failed to call setsockopt(IP_TOS)");
                goto detach;
        }