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 <[email protected]>
---
 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


Reply via email to