aboutsummaryrefslogtreecommitdiff
path: root/arch/sandbox
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2024-04-10 23:50:34 +0200
committerTom Rini <trini@konsulko.com>2024-04-17 17:06:16 -0600
commit2c3fa4b8add3cb6a440184ab67debc6867d383c0 (patch)
tree477536ef7d6a78755acf46f58ae68cd7767a1d69 /arch/sandbox
parentadf418d8c1d43388ebcb5f4ca87e113b27ff934f (diff)
downloadu-boot-2c3fa4b8add3cb6a440184ab67debc6867d383c0.zip
u-boot-2c3fa4b8add3cb6a440184ab67debc6867d383c0.tar.gz
u-boot-2c3fa4b8add3cb6a440184ab67debc6867d383c0.tar.bz2
sandbox: don't call os_close with invalid file descriptor
If open() fails it returns -1. Calling close() with this value makes no sense. Return -EIO instead. Addresses-Coverity-ID: 185828 Improper use of negative value Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Fixes: 566bf3a8698 ("sandbox: Add a function to read a host file") Reviewed-by: Sean Anderson <seanga2@gmail.com>
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/cpu/os.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index cbae510..154a5d7 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -188,7 +188,7 @@ int os_read_file(const char *fname, void **bufp, int *sizep)
fd = os_open(fname, OS_O_RDONLY);
if (fd < 0) {
printf("Cannot open file '%s'\n", fname);
- goto err;
+ return -EIO;
}
size = os_filesize(fd);
if (size < 0) {