[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] linux-user: fix memory leak in failure path
From: |
ajia |
Subject: |
[Qemu-devel] [PATCH] linux-user: fix memory leak in failure path |
Date: |
Wed, 28 Sep 2011 14:57:02 +0800 |
From: Alex Jia <address@hidden>
Haven't released memory of 'array' and 'host_mb' in failure paths.
Signed-off-by: Alex Jia <address@hidden>
---
linux-user/syscall.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7735008..922c2a0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2523,8 +2523,10 @@ static inline abi_long do_semctl(int semid, int semnum,
int cmd,
case GETALL:
case SETALL:
err = target_to_host_semarray(semid, &array, target_su.array);
- if (err)
+ if (err) {
+ free(array);
return err;
+ }
arg.array = array;
ret = get_errno(semctl(semid, semnum, cmd, arg));
err = host_to_target_semarray(semid, target_su.array, &array);
@@ -2779,9 +2781,9 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
}
target_mb->mtype = tswapl(host_mb->mtype);
- free(host_mb);
end:
+ free(host_mb);
if (target_mb)
unlock_user_struct(target_mb, msgp, 1);
return ret;
--
1.7.1