Commit f42d01aa authored by Hongtao Lee's avatar Hongtao Lee Committed by Masami Hiramatsu (Google)
Browse files

tools/bootconfig: Fix buf leaks in apply_xbc

If data calloc failed, free the buf before return.

Link: https://lore.kernel.org/all/20260520030126.147782-1-lihongtao@kylinos.cn/



Fixes: 950313eb ("tools: bootconfig: Add bootconfig command")
Signed-off-by: default avatarHongtao Lee <lihongtao@kylinos.cn>
Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
parent 5200f5f4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -390,8 +390,10 @@ static int apply_xbc(const char *path, const char *xbc_path)

	/* Backup the bootconfig data */
	data = calloc(size + BOOTCONFIG_ALIGN + BOOTCONFIG_FOOTER_SIZE, 1);
	if (!data)
	if (!data) {
		free(buf);
		return -ENOMEM;
	}
	memcpy(data, buf, size);

	/* Check the data format */