Skip to contentSkip to conversation

objtool: orc_gen: Fix memory leak in create_orc_entry

PATCH In review Gustavo A. R. Silva 2 participants 3 messages Apr 27, 2020 objtool

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 objtool: orc_gen: Fix memory leak in create_orc_entry

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")
---
 tools/objtool/orc_gen.c | 1 +
 1 file changed, 1 insertion(+)
tools/objtool/orc_gen.c +1 -0
index 4c0dabd28000..07b67b1576d7 100644
@@ -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;
 		}
 
Signature · 1 line
2.26.0
#1 lore raw
Quoted 6 lines · Gustavo A. R. Silva

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")

Hi Gustavo,

For performance reasons, our policy is to allow memory leaks in error and exit paths. So you may want to turn off Coverity resource leak checking for objtool.

Signature · 1 line
Josh
#2 lore raw

Hi Josh,

Quoted 8 lines · Josh Poimboeuf
Quoted 6 lines · Gustavo A. R. Silva

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")
Quoted 6 lines

Hi Gustavo,

For performance reasons, our policy is to allow memory leaks in error and exit paths. So you may want to turn off Coverity resource leak checking for objtool.

Got it. That's good to know.

Thank you.
--
Gustavo