mirror of
https://github.com/crash-utility/crash
synced 2025-05-12 04:27:57 +00:00
Fix for "help -r" segfault in case of ramdump
When the ELF note does not contain CPU registers, attempting to retrieve online CPU registers will cause a crash. This is likely to happen for ramdump cases as follows, where the ELF header is created by crash at runtime. crash> help -r ... WARNING: cpu 7: cannot find NT_PRSTATUS note KERNEL: vmlinux [TAINTED] DUMPFILES: /var/tmp/ramdump_elf_RabECD [temporary ELF header] DDRCS0_0.BIN ... DDRCS2_2.BIN CPUS: 8 ... With the patch: crash> help -r ... CPU 6: help: registers not collected for cpu 6 ... Lets add a sanity check to avoid the current issue. Signed-off-by: Guanyou.Chen <chenguanyou@xiaomi.com>
This commit is contained in:
parent
e44a9a9d80
commit
aa9f724807
@ -2768,7 +2768,8 @@ display_regs_from_elf_notes(int cpu, FILE *ofp)
|
||||
}
|
||||
}
|
||||
|
||||
if ((cpu - skipped_count) >= nd->num_prstatus_notes &&
|
||||
if (((cpu < 0 ) || (!nd->nt_prstatus_percpu[cpu]) ||
|
||||
(cpu - skipped_count) >= nd->num_prstatus_notes) &&
|
||||
!machine_type("MIPS")) {
|
||||
error(INFO, "registers not collected for cpu %d\n", cpu);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user