[v2,8/8] objtool: explicitly cleanup resources on success

Message ID 20221216-objtool-memory-v2-8-17968f85a464@weissschuh.net
State New
Headers
Series reduce maximum memory usage |

Commit Message

Thomas Weißschuh Dec. 27, 2022, 4:01 p.m. UTC
  Previously the file was only closed and resources properly freed on
errors, not on normal exits.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/objtool/builtin-check.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Josh Poimboeuf Jan. 31, 2023, 12:02 a.m. UTC | #1
On Tue, Dec 27, 2022 at 04:01:04PM +0000, Thomas Weißschuh wrote:
> Previously the file was only closed and resources properly freed on
> errors, not on normal exits.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  tools/objtool/builtin-check.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
> index 7c175198d09f..e11c766b98ce 100644
> --- a/tools/objtool/builtin-check.c
> +++ b/tools/objtool/builtin-check.c
> @@ -229,5 +229,7 @@ int objtool_run(int argc, const char **argv)
>  	if (file->elf->changed)
>  		return elf_write(file->elf);
>  
> +	elf_close(file->elf);
> +
>  	return 0;

I'd rather not unless there's a real benefit to doing this, as it will
just slow down the exit.
  

Patch

diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 7c175198d09f..e11c766b98ce 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -229,5 +229,7 @@  int objtool_run(int argc, const char **argv)
 	if (file->elf->changed)
 		return elf_write(file->elf);
 
+	elf_close(file->elf);
+
 	return 0;
 }