* [Qemu-devel] [PATCH] gdbstub: avoid possible NULL pointer dereference
@ 2015-03-02 12:26 Paolo Bonzini
2015-03-04 14:40 ` Michael Tokarev
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2015-03-02 12:26 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
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>
---
gdbstub.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index e4a1a79..8abcb8a 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
}
--
2.3.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] gdbstub: avoid possible NULL pointer dereference
2015-03-02 12:26 [Qemu-devel] [PATCH] gdbstub: avoid possible NULL pointer dereference Paolo Bonzini
@ 2015-03-04 14:40 ` Michael Tokarev
0 siblings, 0 replies; 2+ messages in thread
From: Michael Tokarev @ 2015-03-04 14:40 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial
Applied to -trivial, thank you!
/mjt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-04 14:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 12:26 [Qemu-devel] [PATCH] gdbstub: avoid possible NULL pointer dereference Paolo Bonzini
2015-03-04 14:40 ` Michael Tokarev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.