Skip to contentSkip to conversation

Coverity: create_orc_entry(): Resource leaks

DISCUSSION coverity-bot 2 participants 2 messages Apr 17, 2020 – Apr 18, 2020 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20200417 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Wed Apr 1 13:23:27 2020 -0500
e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")

Coverity reported the following:

*** CID 1492654: Resource leaks (RESOURCE_LEAK) /tools/objtool/orc_gen.c: 123 in create_orc_entry()

117     			rela->sym = find_symbol_containing(insn_sec,
118     							   insn_off - 1);
119     		}
120     		if (!rela->sym) {
121     			WARN("missing symbol for insn at offset 0x%lx\n",
122     			     insn_off);
vvv     CID 1492654:  Resource leaks  (RESOURCE_LEAK)
vvv     Variable "rela" going out of scope leaks the storage it points to.
123     			return -1;
124     		}

125
126 rela->addend = insn_off - rela->sym->offset;
127 }
128

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

Addresses-Coverity-ID: 1492654 ("Resource leaks")

Fixes e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")

Thanks for your attention!

Signature · 1 line
Coverity-bot
#1 lore raw
Quoted 31 lines · coverity-bot

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20200417 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Wed Apr 1 13:23:27 2020 -0500
e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")

Coverity reported the following:

*** CID 1492654: Resource leaks (RESOURCE_LEAK) /tools/objtool/orc_gen.c: 123 in create_orc_entry()

117     			rela->sym = find_symbol_containing(insn_sec,
118     							   insn_off - 1);
119     		}
120     		if (!rela->sym) {
121     			WARN("missing symbol for insn at offset 0x%lx\n",
122     			     insn_off);
vvv     CID 1492654:  Resource leaks  (RESOURCE_LEAK)
vvv     Variable "rela" going out of scope leaks the storage it points to.
123     			return -1;
124     		}

125
126 rela->addend = insn_off - rela->sym->offset;
127 }
128

Quoted 4 lines

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

This isn't a false positive, but I don't think we care. objtool is a run-once short lived thing. Also, in the above case, if we error we exit, absolutely no point in spending time on freeing memory.