|
From: | Philippe Mathieu-Daudé |
Subject: | Re: [Qemu-devel] [PATCH 2/2] target/i386/monitor.c: check return value of mon_get_cpu before using it |
Date: | Sun, 19 Feb 2017 00:56:46 -0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 |
On 02/17/2017 05:27 AM, Ziyue Yang wrote:
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>
Reviewed-by: Philippe Mathieu-Daudé <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)
[Prev in Thread] | Current Thread | [Next in Thread] |