2021-03-09 08:50:32

by Jiapeng Chong

[permalink] [raw]
Subject: [PATCH] objtool: Fix a memory leak bug

Fix the following cppcheck warnings:

tools/objtool/check.c(1102): error: Memory leak: orig_alt_group.

Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Jiapeng Chong <[email protected]>
---
tools/objtool/check.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 068cdb4..bfa7c31 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1099,6 +1099,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;
}

--
1.8.3.1


2021-03-09 15:36:25

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH] objtool: Fix a memory leak bug

On Tue, Mar 09, 2021 at 04:46:16PM +0800, Jiapeng Chong wrote:
> Fix the following cppcheck warnings:
>
> tools/objtool/check.c(1102): error: Memory leak: orig_alt_group.
>
> Reported-by: Abaci Robot <[email protected]>
> Signed-off-by: Jiapeng Chong <[email protected]>

Hi Jiapeng,

Objtool is a short-running process which exits immediately on error, so
we don't worry about memory leaks.

--
Josh