From 612bf6142fa01cc6a947027a6b2dcb9a4bf6f1de Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 22 Mar 2021 07:55:27 +0100 Subject: sandbox: fix use of initialized variable in error path fd could be uninitialized in some error paths. Give it a value that close can be called on without adverse effect. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/os/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/sandbox/os/common.c') diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index f6b352f2d6..4eb6d37fff 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -321,7 +321,7 @@ int linux_open_hostfile(struct hf_info *hf) { char *buf = NULL; struct stat s; - int fd; + int fd = -1; printf("add %s %sbacked by file %s%s\n", hf->devname, hf->filename ? "" : "initially un", hf->filename ?: "", @@ -408,7 +408,7 @@ int linux_open_hostfile(struct hf_info *hf) return 0; err_out: - if (fd > 0) + if (fd >= 0) close(fd); free(buf); return -1; -- cgit v1.2.3