Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH] tools/bootconfig: Fix null pointer when free buf
@ 2026-05-19  3:14 lihongtao
  2026-05-19 15:04 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: lihongtao @ 2026-05-19  3:14 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: linux-kernel, linux-trace-kernel, lihongtao

In show_xbc() and delete_xbc(), if load_xbc_from_initrd failed,
the buf may be NULL.

Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
Signed-off-by: lihongtao <lihongtao@kylinos.cn>
---
 tools/bootconfig/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index ddabde20585f..417d07a46f92 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -328,7 +328,8 @@ static int show_xbc(const char *path, bool list)
 		xbc_show_compact_tree();
 	ret = 0;
 out:
-	free(buf);
+	if (buf)
+		free(buf);
 
 	return ret;
 }
@@ -360,7 +361,8 @@ static int delete_xbc(const char *path)
 	} /* Ignore if there is no boot config in initrd */
 
 	close(fd);
-	free(buf);
+	if (buf)
+		free(buf);
 
 	return ret;
 }
-- 
2.25.1


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

end of thread, other threads:[~2026-05-19 15:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19  3:14 [PATCH] tools/bootconfig: Fix null pointer when free buf lihongtao
2026-05-19 15:04 ` Masami Hiramatsu

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