* [PATCH] objtool: avoid Memory leak: orig_alt_group
@ 2021-07-02 3:13 gushengxian
2021-07-02 8:26 ` Miroslav Benes
0 siblings, 1 reply; 2+ messages in thread
From: gushengxian @ 2021-07-02 3:13 UTC (permalink / raw)
To: jpoimboe, peterz; +Cc: linux-kernel, gushengxian
From: gushengxian <gushengxian@yulong.com>
free(orig_alt_group) should be added in order to avoid memery leak.
Reported by cppcheck.
Signed-off-by: gushengxian <gushengxian@yulong.com>
---
tools/objtool/check.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e5947fbb9e7a..deb48b1bc16d 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1097,6 +1097,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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] objtool: avoid Memory leak: orig_alt_group
2021-07-02 3:13 [PATCH] objtool: avoid Memory leak: orig_alt_group gushengxian
@ 2021-07-02 8:26 ` Miroslav Benes
0 siblings, 0 replies; 2+ messages in thread
From: Miroslav Benes @ 2021-07-02 8:26 UTC (permalink / raw)
To: gushengxian; +Cc: jpoimboe, peterz, linux-kernel, gushengxian
Hi,
On Thu, 1 Jul 2021, gushengxian wrote:
> From: gushengxian <gushengxian@yulong.com>
>
> free(orig_alt_group) should be added in order to avoid memery leak.
> Reported by cppcheck.
>
> Signed-off-by: gushengxian <gushengxian@yulong.com>
It is not necessary. Objtool would exit immediately in case of this error
and we do not handle the allocations in such cases.
> ---
> tools/objtool/check.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index e5947fbb9e7a..deb48b1bc16d 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -1097,6 +1097,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;
> }
There are more sites like this in the code. For example there is one a
couple of lines later in the same function. It is fine.
Regards
Miroslav
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-02 8:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 3:13 [PATCH] objtool: avoid Memory leak: orig_alt_group gushengxian
2021-07-02 8:26 ` Miroslav Benes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).