Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/mm: Report page_owner_sort output errors
@ 2026-11-20  6:21 Zhu Jun
  2026-11-23 11:10 ` Vlastimil Babka (SUSE)
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-20  6:21 UTC (permalink / raw)
  To: vbabka
  Cc: hannes, surenb, mhocko, brendan.jackman, ziy, akpm, david, ljs,
	liam, rppt, iamjoonsoo.kim, linux-mm, Zhu Jun

page_owner_sort does not check its output stream for errors and relies
on process exit to flush buffered data. For example, writing a small
result to /dev/full returns success even though no output is saved.

Check for earlier stream errors and explicitly close the output before
reporting success, so errors flushing the final buffer also produce a
failing exit status.

Fixes: 48c96a368579 ("mm/page_owner: keep track of page owners")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/mm/page_owner_sort.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
index 48c403d3de4f..13166199ef0d 100644
--- a/tools/mm/page_owner_sort.c
+++ b/tools/mm/page_owner_sort.c
@@ -1024,6 +1024,11 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if (ferror(fout) || fclose(fout)) {
+		perror("write output");
+		exit(1);
+	}
+
 out_free:
 	if (ext_buf)
 		free(ext_buf);




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

end of thread, other threads:[~2026-11-23 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  6:21 [PATCH] tools/mm: Report page_owner_sort output errors Zhu Jun
2026-11-23 11:10 ` Vlastimil Babka (SUSE)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox