[bug report] bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Alexei Starovoitov,

Commit d510296d331a ("bpftool: Use syscall/loader program in "prog
load" and "gen skeleton" command.") from May 13, 2021 (linux-next),
leads to the following Smatch static checker warning:

	./tools/bpf/bpftool/prog.c:1925 do_loader()
	warn: missing error code here? 'bpf_object__open_file()' failed. 'err' = '0'

./tools/bpf/bpftool/prog.c
    1906 static int do_loader(int argc, char **argv)
    1907 {
    1908         DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts);
    1909         DECLARE_LIBBPF_OPTS(gen_loader_opts, gen);
    1910         struct bpf_object *obj;
    1911         const char *file;
    1912         int err = 0;
    1913 
    1914         if (!REQ_ARGS(1))
    1915                 return -1;
    1916         file = GET_ARG();
    1917 
    1918         if (verifier_logs)
    1919                 /* log_level1 + log_level2 + stats, but not stable UAPI */
    1920                 open_opts.kernel_log_level = 1 + 2 + 4;
    1921 
    1922         obj = bpf_object__open_file(file, &open_opts);
    1923         if (!obj) {
    1924                 p_err("failed to open object file");
--> 1925                 goto err_close_obj;

set the error code?

    1926         }
    1927 
    1928         err = bpf_object__gen_loader(obj, &gen);
    1929         if (err)
    1930                 goto err_close_obj;
    1931 
    1932         err = bpf_object__load(obj);
    1933         if (err) {
    1934                 p_err("failed to load object file");
    1935                 goto err_close_obj;
    1936         }
    1937 
    1938         if (verifier_logs) {
    1939                 struct dump_data dd = {};
    1940 
    1941                 kernel_syms_load(&dd);
    1942                 dump_xlated_plain(&dd, (void *)gen.insns, gen.insns_sz, false, false);
    1943                 kernel_syms_destroy(&dd);
    1944         }
    1945         err = try_loader(&gen);
    1946 err_close_obj:
    1947         bpf_object__close(obj);
    1948         return err;
    1949 }

regards,
dan carpenter




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux