diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index 7362bef1a36834df0a72ed06abbde64f523f505c..6cd6080cac04cf44517476b0378ddb500f39bd92 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -399,6 +399,7 @@ static int apply_xbc(const char *path, const char *xbc_path)
 	}
 	/* TODO: Ensure the @path is initramfs/initrd image */
 	if (fstat(fd, &stat) < 0) {
+		ret = -errno;
 		pr_err("Failed to get the size of %s\n", path);
 		goto out;
 	}