]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/bootconfig: Fix buf leaks in apply_xbc
authorHongtao Lee <lihongtao@kylinos.cn>
Wed, 20 May 2026 03:01:26 +0000 (11:01 +0800)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Thu, 21 May 2026 02:42:27 +0000 (11:42 +0900)
If data calloc failed, free the buf before return.

Link: https://lore.kernel.org/all/20260520030126.147782-1-lihongtao@kylinos.cn/
Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
Signed-off-by: Hongtao Lee <lihongtao@kylinos.cn>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
tools/bootconfig/main.c

index 643f707b8f1da1838fb828f8478c7db4800cc855..ddabde20585f2152f9fb2f39525b065e32d4e308 100644 (file)
@@ -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 */