diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2011-11-21 15:43:34 +0800 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2011-11-21 17:49:38 +0900 |
commit | 542dc8b04f0da04a1d440e0feb8c4be7da999114 (patch) | |
tree | d867215606a10740db5d00dfa3283839d900771c | |
parent | cf0ad87f28d48d3414c796734563d8681b751a20 (diff) | |
download | kexec-tools-542dc8b04f0da04a1d440e0feb8c4be7da999114.tar.gz |
kexec: fix several issues in get_crash_notes()
a) We don't need 'crash_notes' array at all, save some bytes on stack.
b) We forgot to fclose 'fp' before return.
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/arch/i386/crashdump-x86.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c index 98cda725..436797aa 100644 --- a/kexec/arch/i386/crashdump-x86.c +++ b/kexec/arch/i386/crashdump-x86.c @@ -589,13 +589,12 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr) */ static int get_crash_notes(int cpu, uint64_t *addr, uint64_t *len) { - char crash_notes[PATH_MAX]; + const char *crash_notes = "/sys/kernel/crash_notes"; char line[MAX_LINE]; FILE *fp; unsigned long vaddr; int count; - sprintf(crash_notes, "/sys/kernel/crash_notes"); fp = fopen(crash_notes, "r"); if (fp) { if (fgets(line, sizeof(line), fp) != 0) { @@ -610,6 +609,7 @@ static int get_crash_notes(int cpu, uint64_t *addr, uint64_t *len) #ifdef DEBUG printf("crash_notes addr = %Lx\n", *addr); #endif + fclose(fp); return 0; } else return get_crash_notes_per_cpu(cpu, addr, len); |