objtool: Free memory in error case in special_get_alts
PATCH 1/1 objtool: Free memory in error case in special_get_alts
Avoid a memory leak in case get_alt_entry returns an error.
Signed-off-by Tobias Klauser <[email protected]>
--- tools/objtool/special.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/objtool/special.c +3 -1
@@ -188,8 +188,10 @@ int special_get_alts(struct elf *elf, struct list_head *alts)memset (alt,0 ,sizeof (*alt)); ret =get_alt_entry (elf, entry, sec, idx, alt); -if (ret) +if (ret) { +free (alt);return ret; + }list_add_tail (&alt->list, alts); }
Signature · 1 line
2.27.0
Hi,
Quoted 1 line · Tobias Klauser
Avoid a memory leak in case
get_alt_entryreturns an error.
yes, this is not the only one, but I doubt we want to spend time on that. The process is about to exit anyway.
Miroslav
Quoted 24 lines
Signed-off-by Tobias Klauser <[email protected]>--- tools/objtool/special.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/objtool/special.c +3
-1@@ -188,8 +188,10 @@ int special_get_alts(struct elf *elf, struct list_head *alts)memset (alt,0 ,sizeof (*alt)); ret =get_alt_entry (elf, entry, sec, idx, alt); -if (ret) +if (ret) { +free (alt);return ret; + }list_add_tail (&alt->list, alts); }Signature · 1 line
2.27.0
Peter Zijlstra
maintainerQuoted 8 lines · Miroslav Benes
Hi,
Quoted 1 line · Tobias Klauser
Avoid a memory leak in case
get_alt_entryreturns an error.yes, this is not the only one, but I doubt we want to spend time on that. The process is about to exit anyway.
Right, that's just wasting cycles.