From 11ea40905259f29e448af816ff00d9d9f0951818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 15 Apr 2012 18:51:01 +0200 Subject: [PATCH] linux-user: Fix exit syscall with QOM CPU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For QOM'ified CPUs we cannot g_free() CPUArchState, we must object_delete() the object it is embedded into. Fixes LP#982321 (invalid free() while executing pacman with qemu-arm). Reported-by: Serge Schneider Reported-by: Russell Keith Davis Signed-off-by: Andreas Färber Reviewed-by: Peter Maydell Tested-by: Serge Schneider Tested-by: Russell Keith Davis Signed-off-by: Blue Swirl --- linux-user/syscall.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8a92162155..712861829a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5045,7 +5045,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, NULL, NULL, 0); } thread_env = NULL; +#ifdef ENV_GET_CPU + object_delete(OBJECT(ENV_GET_CPU(cpu_env))); +#else g_free(cpu_env); +#endif g_free(ts); pthread_exit(NULL); }