From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, Riku Voipio <riku.voipio@iki.fi>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 4/8] linux-user: Fix error handling in flatload.c target_pread()
Date: Tue, 12 Jul 2016 13:02:15 +0100 [thread overview]
Message-ID: <1468324939-12221-5-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1468324939-12221-1-git-send-email-peter.maydell@linaro.org>
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>
---
linux-user/flatload.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 48ad1c5..99492d3 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;
}
--
1.9.1
next prev parent reply other threads:[~2016-07-12 12:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 12:02 [Qemu-devel] [PATCH 0/8] linux-user: fix various coverity nits Peter Maydell
2016-07-12 12:02 ` [Qemu-devel] [PATCH 1/8] linux-user: Pass missing MAP_ANONYMOUS to target_mmap() call Peter Maydell
2016-07-12 12:02 ` [Qemu-devel] [PATCH 2/8] linux-user: Check lock_user() return value for NULL Peter Maydell
2016-07-12 12:02 ` [Qemu-devel] [PATCH 3/8] linux-user: Fix incorrect use of host errno in do_ioctl_dm() Peter Maydell
2016-07-12 12:02 ` Peter Maydell [this message]
2016-07-12 12:02 ` [Qemu-devel] [PATCH 5/8] linux-user: Don't write off end of new_utsname buffer Peter Maydell
2016-07-12 12:02 ` [Qemu-devel] [PATCH 6/8] linux-user: Check dump_write() return in elf_core_dump() Peter Maydell
2016-07-12 12:02 ` [Qemu-devel] [PATCH 7/8] linux-user: Use glib malloc functions in load_symbols() Peter Maydell
2016-07-12 12:02 ` [Qemu-devel] [PATCH 8/8] linux-user: Fix memchr() argument in open_self_cmdline() Peter Maydell
2016-07-12 14:47 ` [Qemu-devel] [PATCH 0/8] linux-user: fix various coverity nits Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468324939-12221-5-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).