diff options
author | zhanghailiang <zhang.zhanghailiang@huawei.com> | 2014-08-14 15:29:18 +0800 |
---|---|---|
committer | Riku Voipio <riku.voipio@linaro.org> | 2014-08-22 15:06:35 +0300 |
commit | 29e03fcb62d413cf5fba06978346893ab72a1f64 (patch) | |
tree | b7513ba75b7ee74c5ce4d184957cc91664abb1cc /linux-user/syscall.c | |
parent | 29560a6cb7a7a705de3d7dfb44e8b1c0a12ad37d (diff) |
linux-user: check return value of malloc()
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Acked-by: Riku Voipio <riku.voipio@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r-- | linux-user/syscall.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ebdc70e4ca..7ff7c21255 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)); |