From: Chen Gang S <gang.chen@sunrus.com.cn>
To: riku.voipio@iki.fi
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-trivial] [PATCH] linux-user/syscall.c: Free the vec[i] in failure processing code block
Date: Fri, 23 Jan 2015 17:36:16 +0800 [thread overview]
Message-ID: <54C21610.7090808@sunrus.com.cn> (raw)
When failure occurs during allocating vec[i], also need free all
allocated vec[i] in failure processing code block before return.
If error is EFAULT when "i == 0", vec[i].iov_base is NULL, then can just
skip it, so can still use "while (--i >= 0)" for the free looping.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
linux-user/syscall.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 290fdea..e6a8e49 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1873,6 +1873,11 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
return vec;
fail:
+ while (--i >= 0) {
+ if (tswapal(vec[i].iov_len) > 0) {
+ unlock_user(vec[i].iov_base, base, 0);
+ }
+ }
unlock_user(target_vec, target_addr, 0);
fail2:
free(vec);
--
1.9.3 (Apple Git-50)
WARNING: multiple messages have this Message-ID (diff)
From: Chen Gang S <gang.chen@sunrus.com.cn>
To: riku.voipio@iki.fi
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] linux-user/syscall.c: Free the vec[i] in failure processing code block
Date: Fri, 23 Jan 2015 17:36:16 +0800 [thread overview]
Message-ID: <54C21610.7090808@sunrus.com.cn> (raw)
When failure occurs during allocating vec[i], also need free all
allocated vec[i] in failure processing code block before return.
If error is EFAULT when "i == 0", vec[i].iov_base is NULL, then can just
skip it, so can still use "while (--i >= 0)" for the free looping.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
linux-user/syscall.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 290fdea..e6a8e49 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1873,6 +1873,11 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
return vec;
fail:
+ while (--i >= 0) {
+ if (tswapal(vec[i].iov_len) > 0) {
+ unlock_user(vec[i].iov_base, base, 0);
+ }
+ }
unlock_user(target_vec, target_addr, 0);
fail2:
free(vec);
--
1.9.3 (Apple Git-50)
next reply other threads:[~2015-01-23 9:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 9:36 Chen Gang S [this message]
2015-01-23 9:36 ` [Qemu-devel] [PATCH] linux-user/syscall.c: Free the vec[i] in failure processing code block Chen Gang S
2015-01-23 9:53 ` [Qemu-trivial] " Chen Gang S
2015-01-23 9:53 ` [Qemu-devel] " Chen Gang S
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=54C21610.7090808@sunrus.com.cn \
--to=gang.chen@sunrus.com.cn \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.