[PATCH] objtool: Fix memory leakage

From: Konstantin Meskhidze
Date: Tue Nov 29 2022 - 21:36:47 EST


This commit fixes memory leakage in handle_group_alt() function.

Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@xxxxxxxxxx>
---
tools/objtool/check.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 43ec14c29a60..2689098e9bad 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1569,6 +1569,7 @@ static int handle_group_alt(struct objtool_file *file,
sizeof(struct cfi_state *));
if (!orig_alt_group->cfi) {
WARN("calloc failed");
+ free(orig_alt_group);
return -1;
}

@@ -1603,6 +1604,7 @@ static int handle_group_alt(struct objtool_file *file,
nop = malloc(sizeof(*nop));
if (!nop) {
WARN("malloc failed");
+ free(new_alt_group);
return -1;
}
memset(nop, 0, sizeof(*nop));
--
2.25.1