summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-03-22 07:55:27 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-22 10:18:42 +0100
commit612bf6142fa01cc6a947027a6b2dcb9a4bf6f1de (patch)
tree5ad4513dd9a3cd07d304ba4282aa7a3a3db6a7a4 /arch/sandbox
parentb09a15ce42f344bd4f4f67ab509b774274920e2c (diff)
downloadbarebox-612bf6142fa01cc6a947027a6b2dcb9a4bf6f1de.tar.gz
barebox-612bf6142fa01cc6a947027a6b2dcb9a4bf6f1de.tar.xz
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 <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/os/common.c4
1 files changed, 2 insertions, 2 deletions
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;