Skip to content

Commit

Permalink
btf: fix return value check in btf_vmlinux_init()
Browse files Browse the repository at this point in the history
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: 341dfcf ("btf: expose BTF info through sysfs")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Wei Yongjun authored and Alexei Starovoitov committed Aug 16, 2019
1 parent 82c4c3b commit e032500
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions kernel/bpf/sysfs_btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ static struct kobject *btf_kobj;

static int __init btf_vmlinux_init(void)
{
int err;

if (!_binary__btf_vmlinux_bin_start)
return 0;

btf_kobj = kobject_create_and_add("btf", kernel_kobj);
if (IS_ERR(btf_kobj)) {
err = PTR_ERR(btf_kobj);
btf_kobj = NULL;
return err;
}
if (!btf_kobj)
return -ENOMEM;

bin_attr_btf_vmlinux.size = _binary__btf_vmlinux_bin_end -
_binary__btf_vmlinux_bin_start;
Expand Down

0 comments on commit e032500

Please sign in to comment.