提交 7eff518b 编写于 作者: C Chen Gang S 提交者: Michael Tokarev

linux-user/syscall.c: lock_iovec: unlock vec[i] in failure processing code block

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: NChen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 88ea8ed7
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册