aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-07-12 13:02:15 +0100
committerRiku Voipio <riku.voipio@linaro.org>2016-09-21 14:27:19 +0300
commite5a869ed569a97fa676e9827952629086ec41f4e (patch)
tree178c04b6899a262e02c08a44ed829ca9f4873ed6
parentf9757b1d9649cb739ecf544c7137c0885281f6e8 (diff)
downloadqemu-e5a869ed569a97fa676e9827952629086ec41f4e.zip
qemu-e5a869ed569a97fa676e9827952629086ec41f4e.tar.gz
qemu-e5a869ed569a97fa676e9827952629086ec41f4e.tar.bz2
linux-user: Fix error handling in flatload.c target_pread()
The flatload.c target_pread() function is supposed to return 0 on success or negative host errnos; however it wasn't checking lock_user() for failure or returning the errno from the pread() call. Fix these problems (the first of which is noted by Coverity). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
-rw-r--r--linux-user/flatload.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 42d1079..a35a560 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -95,7 +95,13 @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len,
int ret;
buf = lock_user(VERIFY_WRITE, ptr, len, 0);
+ if (!buf) {
+ return -EFAULT;
+ }
ret = pread(fd, buf, len, offset);
+ if (ret < 0) {
+ ret = -errno;
+ }
unlock_user(buf, ptr, len);
return ret;
}