qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 09/46] linux-user/syscall.c: lock_iovec: unlock vec[i


From: Michael Tokarev
Subject: [Qemu-devel] [PULL 09/46] linux-user/syscall.c: lock_iovec: unlock vec[i] in failure processing code block
Date: Tue, 10 Feb 2015 09:33:58 +0300

From: Chen Gang S <address@hidden>

When failure occurs during locking of vec[i], we also need to unlock all
already locked vec[i] in failure processing code block before return.

Code in unlock_user() checks vec[i].iov_base for NULL, so there's no
need not check it .

If error is EFAULT when "i == 0", vec[i].iov_base is NULL, we can just
skip it, so can still use "while (--i >= 0)" loop condition.

Signed-off-by: Chen Gang <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
 linux-user/syscall.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d4398b9..7b6f482 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1883,6 +1883,11 @@ static struct iovec *lock_iovec(int type, abi_ulong 
target_addr,
     return vec;
 
  fail:
+    while (--i >= 0) {
+        if (tswapal(target_vec[i].iov_len) > 0) {
+            unlock_user(vec[i].iov_base, tswapal(target_vec[i].iov_base), 0);
+        }
+    }
     unlock_user(target_vec, target_addr, 0);
  fail2:
     free(vec);
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]