diff --git a/gdbstub.c b/gdbstub.c index e4a1a793843f259b62c50709eace79144ee7c299..8abcb8a45126a8e0b50a05d837eff851db5dab43 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1443,15 +1443,17 @@ void gdb_exit(CPUArchState *env, int code) if (gdbserver_fd < 0 || s->fd < 0) { return; } +#else + if (!s->chr) { + return; + } #endif snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); put_packet(s, buf); #ifndef CONFIG_USER_ONLY - if (s->chr) { - qemu_chr_delete(s->chr); - } + qemu_chr_delete(s->chr); #endif }