linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] objtool: Free memory in error case in special_get_alts
@ 2020-06-12 11:56 Tobias Klauser
  2020-06-15 10:40 ` Miroslav Benes
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Klauser @ 2020-06-12 11:56 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra; +Cc: linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] objtool: Free memory in error case in special_get_alts
  2020-06-12 11:56 [PATCH] objtool: Free memory in error case in special_get_alts Tobias Klauser
@ 2020-06-15 10:40 ` Miroslav Benes
  2020-06-15 10:47   ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Miroslav Benes @ 2020-06-15 10:40 UTC (permalink / raw)
  To: Tobias Klauser; +Cc: Josh Poimboeuf, Peter Zijlstra, linux-kernel

Hi,

On Fri, 12 Jun 2020, Tobias Klauser wrote:

> Avoid a memory leak in case get_alt_entry returns 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

> 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
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] objtool: Free memory in error case in special_get_alts
  2020-06-15 10:40 ` Miroslav Benes
@ 2020-06-15 10:47   ` Peter Zijlstra
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2020-06-15 10:47 UTC (permalink / raw)
  To: Miroslav Benes; +Cc: Tobias Klauser, Josh Poimboeuf, linux-kernel

On Mon, Jun 15, 2020 at 12:40:32PM +0200, Miroslav Benes wrote:
> Hi,
> 
> On Fri, 12 Jun 2020, Tobias Klauser wrote:
> 
> > Avoid a memory leak in case get_alt_entry returns 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-15 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 11:56 [PATCH] objtool: Free memory in error case in special_get_alts Tobias Klauser
2020-06-15 10:40 ` Miroslav Benes
2020-06-15 10:47   ` Peter Zijlstra

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).