Commit e0325006 authored by Wei Yongjun's avatar Wei Yongjun Committed by Alexei Starovoitov

btf: fix return value check in btf_vmlinux_init()

In case of error, the function kobject_create_and_add() returns NULL
pointer not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.

Fixes: 341dfcf8 ("btf: expose BTF info through sysfs")
Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 82c4c3b7
...@@ -30,17 +30,12 @@ static struct kobject *btf_kobj; ...@@ -30,17 +30,12 @@ static struct kobject *btf_kobj;
static int __init btf_vmlinux_init(void) static int __init btf_vmlinux_init(void)
{ {
int err;
if (!_binary__btf_vmlinux_bin_start) if (!_binary__btf_vmlinux_bin_start)
return 0; return 0;
btf_kobj = kobject_create_and_add("btf", kernel_kobj); btf_kobj = kobject_create_and_add("btf", kernel_kobj);
if (IS_ERR(btf_kobj)) { if (!btf_kobj)
err = PTR_ERR(btf_kobj); return -ENOMEM;
btf_kobj = NULL;
return err;
}
bin_attr_btf_vmlinux.size = _binary__btf_vmlinux_bin_end - bin_attr_btf_vmlinux.size = _binary__btf_vmlinux_bin_end -
_binary__btf_vmlinux_bin_start; _binary__btf_vmlinux_bin_start;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment