Skip to content

Commit

Permalink
libbpf: Propagate errors when retrieving enum value for typed data di…
Browse files Browse the repository at this point in the history
…splay

When retrieving the enum value associated with typed data during
"is data zero?" checking in btf_dump_type_data_check_zero(), the
return value of btf_dump_get_enum_value() is not passed to the caller
if the function returns a non-zero (error) value.  Currently, 0
is returned if the function returns an error.  We should instead
propagate the error to the caller.

Signed-off-by: Alan Maguire <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
alan-maguire authored and anakryiko committed Jul 20, 2021
1 parent a17553d commit 720c29f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/lib/bpf/btf_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -2166,8 +2166,9 @@ static int btf_dump_type_data_check_zero(struct btf_dump *d,
return -ENODATA;
}
case BTF_KIND_ENUM:
if (btf_dump_get_enum_value(d, t, data, id, &value))
return 0;
err = btf_dump_get_enum_value(d, t, data, id, &value);
if (err)
return err;
if (value == 0)
return -ENODATA;
return 0;
Expand Down

0 comments on commit 720c29f

Please sign in to comment.