[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] target/i386/monitor.c: check return value of mo
From: |
Ziyue Yang |
Subject: |
[Qemu-devel] [PATCH 2/2] target/i386/monitor.c: check return value of mon_get_cpu before using it |
Date: |
Fri, 17 Feb 2017 16:27:04 +0800 |
From: Ziyue Yang <address@hidden>
This patch eliminates the segfault caused by accessing CPU that doesn't
exist in hmp command "info lapic", which can be reproduced by
$ qemu-system-x86_64 -nographic -M none -serial none -monitor stdio
and then type "info lapic" into qemu monitor.
Signed-off-by: Ziyue Yang <address@hidden>
---
target/i386/monitor.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 468aa073bc..7b96c74a24 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -624,8 +624,11 @@ const MonitorDef *target_monitor_defs(void)
void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
{
- x86_cpu_dump_local_apic_state(mon_get_cpu(), (FILE *)mon, monitor_fprintf,
- CPU_DUMP_FPU);
+ CPUState *cs = mon_get_cpu();
+ if (cs) {
+ x86_cpu_dump_local_apic_state(cs, (FILE *)mon, monitor_fprintf,
+ CPU_DUMP_FPU);
+ }
}
void hmp_info_io_apic(Monitor *mon, const QDict *qdict)
--
2.11.0