diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-03-02 13:26:58 +0100 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2015-03-10 08:15:34 +0300 |
commit | 3d0f44189178aab3a21a33ecf6a113b9abaea2bc (patch) | |
tree | 467b8b699bbe644ac4e60a624ed3d905ca272444 /gdbstub.c | |
parent | c6dc3dd72b747a057770087998a1f9ef0b3f1882 (diff) |
gdbstub: avoid possible NULL pointer dereference
Coverity reports that s->chr is checked after put_packet dereferences it.
Move the check earlier, consistent with the code used for user-mode
emulation.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'gdbstub.c')
-rw-r--r-- | gdbstub.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 } |