From 45a787761f011fb59833db0edd428a7110a40eeb Mon Sep 17 00:00:00 2001 From: HATAYAMA Daisuke Date: Thu, 25 Oct 2012 12:00:03 +0900 Subject: [PATCH] netdump: fix potencial panic_task detection bug Move a check for crashing_cpu in an inner position so that nd->nt_prstatus is not wrongly used when nd->num_prstatus_notes > 1 but crashing_cpu == 1. Signed-off-by: HATAYAMA Daisuke --- netdump.c | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/netdump.c b/netdump.c index c16eaab..92d4681 100644 --- a/netdump.c +++ b/netdump.c @@ -768,12 +768,13 @@ get_netdump_panic_task(void) } if (nd->elf32 && (nd->elf32->e_machine == EM_386)) { - Elf32_Nhdr *note32; + Elf32_Nhdr *note32 = NULL; - if ((nd->num_prstatus_notes > 1) && (crashing_cpu != -1)) - note32 = (Elf32_Nhdr *) - nd->nt_prstatus_percpu[crashing_cpu]; - else + if (nd->num_prstatus_notes > 1) { + if (crashing_cpu != -1) + note32 = (Elf32_Nhdr *) + nd->nt_prstatus_percpu[crashing_cpu]; + } else note32 = (Elf32_Nhdr *)nd->nt_prstatus; if (!note32) @@ -815,12 +816,13 @@ check_ebp_esp: } } } else if (nd->elf64) { - Elf64_Nhdr *note64; + Elf64_Nhdr *note64 = NULL; - if ((nd->num_prstatus_notes > 1) && (crashing_cpu != -1)) - note64 = (Elf64_Nhdr *) - nd->nt_prstatus_percpu[crashing_cpu]; - else + if (nd->num_prstatus_notes > 1) { + if (crashing_cpu != -1) + note64 = (Elf64_Nhdr *) + nd->nt_prstatus_percpu[crashing_cpu]; + } else note64 = (Elf64_Nhdr *)nd->nt_prstatus; if (!note64) -- 1.7.7.6