lkml.org 
[lkml]   [2020]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] objtool: Free memory in error case in special_get_alts
Date
Avoid a memory leak in case get_alt_entry returns an error.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
tools/objtool/special.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/special.c b/tools/objtool/special.c
index e74e0189de22..f6f7dee1ba77 100644
--- a/tools/objtool/special.c
+++ b/tools/objtool/special.c
@@ -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);
}
--
2.27.0
\
 
 \ /
  Last update: 2020-06-12 13:56    [W:0.038 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site