Prevent "help -r" and "help -[D|n]" from generating a segmentation

violation when attempting to access non-existent NT_PRSTATUS notes
for offline cpus in ELF or compressed kdumps.
(anderson@redhat.com)
This commit is contained in:
Dave Anderson 2015-01-21 15:57:11 -05:00
parent 1818552d18
commit ac9e38a45f
2 changed files with 8 additions and 3 deletions

View File

@ -1801,8 +1801,9 @@ __diskdump_memory_dump(FILE *fp)
fprintf(fp, " num_prstatus_notes: %d\n",
dd->num_prstatus_notes);
for (i = 0; i < dd->num_prstatus_notes; i++) {
fprintf(fp, " notes[%d]: %lx (NT_PRSTATUS)\n",
i, (ulong)dd->nt_prstatus_percpu[i]);
fprintf(fp, " notes[%d]: %lx %s\n",
i, (ulong)dd->nt_prstatus_percpu[i],
dd->nt_prstatus_percpu[i] ? "(NT_PRSTATUS)" : "");
display_ELF_note(dd->machine_type, PRSTATUS_NOTE,
dd->nt_prstatus_percpu[i], fp);
}
@ -2089,7 +2090,8 @@ diskdump_display_regs(int cpu, FILE *ofp)
char *user_regs;
size_t len;
if ((cpu < 0) || (cpu >= dd->num_prstatus_notes)) {
if ((cpu < 0) || (cpu >= dd->num_prstatus_notes) ||
(dd->nt_prstatus_percpu[cpu] == NULL)) {
error(INFO, "registers not collected for cpu %d\n", cpu);
return;
}

View File

@ -2970,6 +2970,9 @@ display_prstatus_ppc64(void *note_ptr, FILE *ofp)
void
display_ELF_note(int machine, int type, void *note, FILE *ofp)
{
if (note == NULL)
return;
switch (machine)
{
case EM_386: