[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 31/38] linux-user: Use g_try_malloc() in do_msgrcv
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL v2 31/38] linux-user: Use g_try_malloc() in do_msgrcv() |
Date: |
Fri, 27 May 2016 16:00:22 +0300 |
From: Peter Maydell <address@hidden>
In do_msgrcv() we want to allocate a message buffer, whose size
is passed to us by the guest. That means we could legitimately
fail, so use g_try_malloc() and handle the error case, in the same
way that do_msgsnd() does.
Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index cec5b80..40e8742 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3167,7 +3167,11 @@ static inline abi_long do_msgrcv(int msqid, abi_long
msgp,
if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0))
return -TARGET_EFAULT;
- host_mb = g_malloc(msgsz+sizeof(long));
+ host_mb = g_try_malloc(msgsz + sizeof(long));
+ if (!host_mb) {
+ ret = -TARGET_ENOMEM;
+ goto end;
+ }
ret = get_errno(msgrcv(msqid, host_mb, msgsz, msgtyp, msgflg));
if (ret > 0) {
--
2.1.4
- [Qemu-devel] [PULL v2 20/38] linux-user: Support for restarting system calls for Microblaze targets, (continued)
- [Qemu-devel] [PULL v2 20/38] linux-user: Support for restarting system calls for Microblaze targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 21/38] linux-user: Add debug code to exercise restarting system calls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 19/38] linux-user: Set r14 on exit from microblaze syscall, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 22/38] linux-user: Provide safe_syscall for fixing races between signals and syscalls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 24/38] linux-user: Use safe_syscall for open and openat system calls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 25/38] linux-user: Use safe_syscall for wait system calls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 29/38] linux-user: Handle negative values in timespec conversion, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 26/38] linux-user: Use safe_syscall for execve syscall, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 27/38] linux-user: Use safe_syscall for pselect, select syscalls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 28/38] linux-user: Use safe_syscall for futex syscall, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 31/38] linux-user: Use g_try_malloc() in do_msgrcv(),
riku . voipio <=
- [Qemu-devel] [PULL v2 33/38] linux-user: Use direct syscalls for setuid(), etc, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 34/38] linux-user: arm: Remove ARM_cpsr and similar #defines, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 30/38] linux-user: Handle msgrcv error case correctly, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 32/38] linux-user: x86_64: Don't use 16-bit UIDs, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 35/38] linux-user/signal.c: Generate opcode data for restorer in setup_rt_frame, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 37/38] linux-user/signal.c: Use s390 target space address instead of host space, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 36/38] linux-user/signal.c: Use target address instead of host address for microblaze restorer, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 38/38] linux-user, target-ppc: fix use of MSR_LE, riku . voipio, 2016/05/27
- Re: [Qemu-devel] [PULL v2 00/38] linux-user pull request, Peter Maydell, 2016/05/27