summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Christophe Dubois <jcd@tribudubois.net>2009-05-17 18:38:39 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-20 13:21:36 -0500
commitfe54857a130d8ce9e9f9b93b3e45e1d4c5ac9529 (patch)
tree51c431dbbad89e7d01aca7fe9c97de7942b350f0
parentee60269c23bb2f672a9617cf36e74d43dc31a5aa (diff)
downloadqemu-fe54857a130d8ce9e9f9b93b3e45e1d4c5ac9529.tar.gz
Fix NULL alarm_timer pointer at exit
This fixes a SIGSEGV error on qemu exit. Here is the valgrind output related to this error ==3648== Process terminating with default action of signal 11 (SIGSEGV) ==3648== Access not within mapped region at address 0x8 ==3648== at 0x40636B: host_alarm_handler (vl.c:1345) ==3648== by 0x52D807F: (within /lib/libpthread-2.9.so) ==3648== by 0x5C0A12E: tcsetattr (in /lib/libc-2.9.so) ==3648== by 0x4DD601: term_exit (qemu-char.c:700) ==3648== by 0x5B636EC: exit (in /lib/libc-2.9.so) ==3648== by 0x5B4B5AC: (below main) (in /lib/libc-2.9.so) This simple fix check for a valid pointer as host_alarm_handler is also called after alarm_timer is released in the exit path. Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--vl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/vl.c b/vl.c
index ca4255a86a..efe29c93d2 100644
--- a/vl.c
+++ b/vl.c
@@ -894,7 +894,7 @@ struct qemu_alarm_timer {
static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
{
- return t->flags & ALARM_FLAG_DYNTICKS;
+ return t && (t->flags & ALARM_FLAG_DYNTICKS);
}
static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t)
@@ -1338,7 +1338,7 @@ static void host_alarm_handler(int host_signum)
static const char byte = 0;
write(alarm_timer_wfd, &byte, sizeof(byte));
#endif
- alarm_timer->flags |= ALARM_FLAG_EXPIRED;
+ if (alarm_timer) alarm_timer->flags |= ALARM_FLAG_EXPIRED;
if (env) {
/* stop the currently executing cpu because a timer occured */