[PATCH] objtool: orc_gen: Fix memory leak in create_orc_entry

From: Gustavo A. R. Silva
Date: Mon Apr 27 2020 - 09:31:18 EST


In case memory resources for rela were allocated, release them before
return.

Addresses-Coverity-ID: 1462331 ("Resource leak")
Fixes: e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
Signed-off-by: Gustavo A. R. Silva <gustavo@xxxxxxxxxxxxxx>
---
tools/objtool/orc_gen.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
index 4c0dabd28000..07b67b1576d7 100644
--- a/tools/objtool/orc_gen.c
+++ b/tools/objtool/orc_gen.c
@@ -120,6 +120,7 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
if (!rela->sym) {
WARN("missing symbol for insn at offset 0x%lx\n",
insn_off);
+ free(rela);
return -1;
}

--
2.26.0