diff options
author | Tom Rini <trini@konsulko.com> | 2023-11-15 14:15:21 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-11-15 14:15:21 -0500 |
commit | 169c3cc49e40758956ee6c310f7f59a6443826a1 (patch) | |
tree | 469779cc9196adce361abe56c2ce27a6563e98ce /arch/sandbox/cpu/os.c | |
parent | 92b27528d777ce85362af45e7d2974a6c856219b (diff) | |
parent | 0d4d9f94c555577f78cddc372c307465fc92413e (diff) |
Merge tag 'dm-pull-15nov23' of https://source.denx.de/u-boot/custodians/u-boot-dm
patman correct import of u_boot_pylib
correct long-standing EFI framebuffer bug
minor test refactor
Diffstat (limited to 'arch/sandbox/cpu/os.c')
-rw-r--r-- | arch/sandbox/cpu/os.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 85d0d6a1703..95c26d855ab 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -219,7 +219,7 @@ int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep) { void *ptr; off_t size; - int ifd; + int ifd, ret = 0; ifd = os_open(pathname, os_flags); if (ifd < 0) { @@ -229,23 +229,28 @@ int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep) size = os_filesize(ifd); if (size < 0) { printf("Cannot get file size of '%s'\n", pathname); - return -EIO; + ret = -EIO; + goto out; } if ((unsigned long long)size > (unsigned long long)SIZE_MAX) { printf("File '%s' too large to map\n", pathname); - return -EIO; + ret = -EIO; + goto out; } ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, ifd, 0); if (ptr == MAP_FAILED) { printf("Can't map file '%s': %s\n", pathname, strerror(errno)); - return -EPERM; + ret = -EPERM; + goto out; } *bufp = ptr; *sizep = size; - return 0; +out: + os_close(ifd); + return ret; } int os_unmap(void *buf, int size) |