mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 14:11:20 +00:00
tools lib bpf: Make bpf_program__get_private() use IS_ERR()
For consistency with bpf_map__priv() and elsewhere. Acked-by: Wang Nan <wangnan0@huawei.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/n/tip-x17nk5mrazkf45z0l0ahlmo8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
a7fe0450b0
commit
be834ffbd1
3 changed files with 15 additions and 20 deletions
|
@ -380,15 +380,14 @@ preproc_gen_prologue(struct bpf_program *prog, int n,
|
|||
struct bpf_insn *orig_insns, int orig_insns_cnt,
|
||||
struct bpf_prog_prep_result *res)
|
||||
{
|
||||
struct bpf_prog_priv *priv = bpf_program__priv(prog);
|
||||
struct probe_trace_event *tev;
|
||||
struct perf_probe_event *pev;
|
||||
struct bpf_prog_priv *priv;
|
||||
struct bpf_insn *buf;
|
||||
size_t prologue_cnt = 0;
|
||||
int i, err;
|
||||
|
||||
err = bpf_program__get_private(prog, (void **)&priv);
|
||||
if (err || !priv)
|
||||
if (IS_ERR(priv) || !priv)
|
||||
goto errout;
|
||||
|
||||
pev = &priv->pev;
|
||||
|
@ -535,13 +534,12 @@ static int map_prologue(struct perf_probe_event *pev, int *mapping,
|
|||
|
||||
static int hook_load_preprocessor(struct bpf_program *prog)
|
||||
{
|
||||
struct bpf_prog_priv *priv = bpf_program__priv(prog);
|
||||
struct perf_probe_event *pev;
|
||||
struct bpf_prog_priv *priv;
|
||||
bool need_prologue = false;
|
||||
int err, i;
|
||||
|
||||
err = bpf_program__get_private(prog, (void **)&priv);
|
||||
if (err || !priv) {
|
||||
if (IS_ERR(priv) || !priv) {
|
||||
pr_debug("Internal error when hook preprocessor\n");
|
||||
return -BPF_LOADER_ERRNO__INTERNAL;
|
||||
}
|
||||
|
@ -607,9 +605,11 @@ int bpf__probe(struct bpf_object *obj)
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
err = bpf_program__get_private(prog, (void **)&priv);
|
||||
if (err || !priv)
|
||||
priv = bpf_program__priv(prog);
|
||||
if (IS_ERR(priv) || !priv) {
|
||||
err = PTR_ERR(priv);
|
||||
goto out;
|
||||
}
|
||||
pev = &priv->pev;
|
||||
|
||||
err = convert_perf_probe_events(pev, 1);
|
||||
|
@ -645,13 +645,12 @@ int bpf__unprobe(struct bpf_object *obj)
|
|||
{
|
||||
int err, ret = 0;
|
||||
struct bpf_program *prog;
|
||||
struct bpf_prog_priv *priv;
|
||||
|
||||
bpf_object__for_each_program(prog, obj) {
|
||||
struct bpf_prog_priv *priv = bpf_program__priv(prog);
|
||||
int i;
|
||||
|
||||
err = bpf_program__get_private(prog, (void **)&priv);
|
||||
if (err || !priv)
|
||||
if (IS_ERR(priv) || !priv)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < priv->pev.ntevs; i++) {
|
||||
|
@ -702,14 +701,12 @@ int bpf__foreach_tev(struct bpf_object *obj,
|
|||
int err;
|
||||
|
||||
bpf_object__for_each_program(prog, obj) {
|
||||
struct bpf_prog_priv *priv = bpf_program__priv(prog);
|
||||
struct probe_trace_event *tev;
|
||||
struct perf_probe_event *pev;
|
||||
struct bpf_prog_priv *priv;
|
||||
int i, fd;
|
||||
|
||||
err = bpf_program__get_private(prog,
|
||||
(void **)&priv);
|
||||
if (err || !priv) {
|
||||
if (IS_ERR(priv) || !priv) {
|
||||
pr_debug("bpf: failed to get private field\n");
|
||||
return -BPF_LOADER_ERRNO__INTERNAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue