hmp: fix "info cpu" segfault
PATCH 1/1 hmp: fix "info cpu" segfault
Running "dump-guest-memory /dev/null 0 8192" results in segfault. Fix by checking if we have CPU.
--- target/i386/arch_dump.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
target/i386/arch_dump.c +4 -3
@@ -390,9 +390,10 @@ int cpu_get_dump_info(ArchDumpInfo *info,GuestPhysBlock *block;#ifdef TARGET_X86_64 -X86CPU *first_x86_cpu =X86_CPU (first_cpu); - - lma = !!(first_x86_cpu->env.hflags &HF_LMA_MASK ); +X86CPU *first_x86_cpu =NULL ; + first_x86_cpu =X86_CPU (first_cpu); +if (first_cpu !=NULL ) + lma = !!(first_x86_cpu->env.hflags &HF_LMA_MASK );#endif if (lma) {
Signature · 1 line
2.12.0
Quoted 3 lines · Iwona Kotlarska
Running "dump-guest-memory
/dev/null0 8192" results in segfault. Fix by checking if we have CPU.
Hi Iwona,
Thank you for contributing to the QEMU project.
Please state the whole command line that causes the problem, not only the hmp command:
Running QEMU with "qemu-system-x86_64 -M none -nographic -m 256" and executing "dump-guest-memory /dev/null 0 8192" results in segfault. Fix this by...
Quoted 10 lines
Signed-off-by Iwona Kotlarska <[email protected]>--- target/i386/arch_dump.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)target/i386/arch_dump.c +0
-0
target/i386/arch_dump.c int cpu_get_dump_info(ArchDumpInfo *info, · line 394
Quoted 8 lines
target/i386/arch_dump.c +2
-3@@ -390,9 +390,10 @@ int cpu_get_dump_info(ArchDumpInfo *info,GuestPhysBlock *block;#ifdef TARGET_X86_64 -X86CPU *first_x86_cpu =X86_CPU (first_cpu); - - lma = !!(first_x86_cpu->env.hflags &HF_LMA_MASK ); +X86CPU *first_x86_cpu =NULL ; + first_x86_cpu =X86_CPU (first_cpu);
You didn't need to break the above in two lines,
but is not a big issue either.
target/i386/arch_dump.c int cpu_get_dump_info(ArchDumpInfo *info, · line 396
Quoted 2 lines
target/i386/arch_dump.c +2
-0+if (first_cpu !=NULL ) + lma = !!(first_x86_cpu->env.hflags &HF_LMA_MASK );
Please run: ./scripts/checkpatch.pl on the patch before you submit to ensure coding style.
You will see that we always use if { }; the patch has "DOS line endings".
You are welcome to submit the patch again.
In the meantime:
Thanks,
Marcel
Quoted 4 lines
target/i386/arch_dump.c +0
-0#endif if (lma) {