提交 bdca2601 编写于 作者: A Alan Maguire 提交者: Zheng Zengkai

libbpf: Propagate errors when retrieving enum value for typed data display

mainline inclusion
from mainline-5.15-rc1
commit 720c29fc
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=720c29fca9fb87c473148ff666b75314420cdda6

-------------------------------------------------

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: NAlan Maguire <alan.maguire@oracle.com>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1626770993-11073-4-git-send-email-alan.maguire@oracle.com
(cherry picked from commit 720c29fc)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 4cf677f0
...@@ -2171,8 +2171,9 @@ static int btf_dump_type_data_check_zero(struct btf_dump *d, ...@@ -2171,8 +2171,9 @@ static int btf_dump_type_data_check_zero(struct btf_dump *d,
return -ENODATA; return -ENODATA;
} }
case BTF_KIND_ENUM: case BTF_KIND_ENUM:
if (btf_dump_get_enum_value(d, t, data, id, &value)) err = btf_dump_get_enum_value(d, t, data, id, &value);
return 0; if (err)
return err;
if (value == 0) if (value == 0)
return -ENODATA; return -ENODATA;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册