Thread (34 messages) flat view 34 messages, 2 authors, 1d ago
WARM1d

[PATCH v3 28/28] fixup! objtool: Add options to write/read exported noreturns to/from a file

From: Josh Poimboeuf <jpoimboe@kernel.org>
Date: 2026-09-21 22:31:52
Also in: lkml, rust-for-linux
Subsystem: objtool, the rest · Maintainers: Josh Poimboeuf, Peter Zijlstra, Linus Torvalds

Fix resource leaks on error paths in write_noreturns(): free buf on
fopen() failure, and free buf + fclose fp on fwrite() failure.

Found by Sashiko review.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/check.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 626402023e4a3..8d1448cdb40ca 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -350,11 +350,14 @@ static int write_noreturns(struct objtool_file *file)
 	fp = fopen(opts.noreturns_write, "w");
 	if (!fp) {
 		ERROR_GLIBC("fopen");
+		free(buf);
 		return -1;
 	}
 
 	if (fwrite(buf, 1, len, fp) != len) {
 		ERROR_GLIBC("fwrite");
+		free(buf);
+		fclose(fp);
 		return -1;
 	}
 
-- 
2.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help