Skip to content

Commit

Permalink
bpf: fix return in load_bpf_file
Browse files Browse the repository at this point in the history
The function load_bpf_file ignores the return value of
load_and_attach(), so even if load_and_attach() returns an error,
load_bpf_file() will return 0.

Now, load_bpf_file() can call load_and_attach() multiple times and some
can succeed and some could fail. I think the correct behavor is to
return error on the first failed load_and_attach().

v2: Added missing SOB

Signed-off-by: Lawrence Brakmo <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Lawrence Brakmo authored and davem330 committed Jul 5, 2017
1 parent ca4a1cd commit f856e46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions samples/bpf/bpf_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,12 @@ static int do_load_bpf_file(const char *path, fixup_map_cb fixup_map)
memcmp(shname, "perf_event", 10) == 0 ||
memcmp(shname, "socket", 6) == 0 ||
memcmp(shname, "cgroup/", 7) == 0 ||
memcmp(shname, "sockops", 7) == 0)
load_and_attach(shname, data->d_buf, data->d_size);
memcmp(shname, "sockops", 7) == 0) {
ret = load_and_attach(shname, data->d_buf,
data->d_size);
if (ret != 0)
goto done;
}
}

ret = 0;
Expand Down

0 comments on commit f856e46

Please sign in to comment.