Merge tag 'perf-core-for-mingo-5.1-20190321' of git://git.kernel.org/pub/scm/linux...
[sfrench/cifs-2.6.git] / tools / lib / bpf / libbpf.c
index 8fb6e89b4b2c3cf0f9b93956684861f03cdb3ffb..e6ad87512519f559156b74f856b59c4855ee5c6e 100644 (file)
@@ -843,6 +843,8 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
                        if (IS_ERR(obj->btf) || btf__load(obj->btf)) {
                                pr_warning("Error loading ELF section %s: %ld. Ignored and continue.\n",
                                           BTF_ELF_SEC, PTR_ERR(obj->btf));
+                               if (!IS_ERR(obj->btf))
+                                       btf__free(obj->btf);
                                obj->btf = NULL;
                        }
                } else if (strcmp(name, BTF_EXT_ELF_SEC) == 0) {