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: 950313ebf7 ("tools: bootconfig: Add bootconfig command")
Signed-off-by: Hongtao Lee <lihongtao@kylinos.cn>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
master
parent
5200f5f493
commit
f42d01aadc
|
|
@ -390,8 +390,10 @@ static int apply_xbc(const char *path, const char *xbc_path)
|
||||||
|
|
||||||
/* Backup the bootconfig data */
|
/* Backup the bootconfig data */
|
||||||
data = calloc(size + BOOTCONFIG_ALIGN + BOOTCONFIG_FOOTER_SIZE, 1);
|
data = calloc(size + BOOTCONFIG_ALIGN + BOOTCONFIG_FOOTER_SIZE, 1);
|
||||||
if (!data)
|
if (!data) {
|
||||||
|
free(buf);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
memcpy(data, buf, size);
|
memcpy(data, buf, size);
|
||||||
|
|
||||||
/* Check the data format */
|
/* Check the data format */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue