qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PULL 24/24] linux-user: check return value of malloc()


From: riku . voipio
Subject: [Qemu-devel] [PULL 24/24] linux-user: check return value of malloc()
Date: Fri, 15 Aug 2014 14:01:42 +0300

From: zhanghailiang <address@hidden>

Signed-off-by: zhanghailiang <address@hidden>
Acked-by: Riku Voipio <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
 linux-user/syscall.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3b1beff..3aaed81 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2904,6 +2904,10 @@ static inline abi_long do_msgsnd(int msqid, abi_long 
msgp,
     if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
         return -TARGET_EFAULT;
     host_mb = malloc(msgsz+sizeof(long));
+    if (!host_mb) {
+        unlock_user_struct(target_mb, msgp, 0);
+        return -TARGET_ENOMEM;
+    }
     host_mb->mtype = (abi_long) tswapal(target_mb->mtype);
     memcpy(host_mb->mtext, target_mb->mtext, msgsz);
     ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));
-- 
2.0.1




reply via email to

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