[Patch] kexec: fix several issues in get_crash_notes()

Cong Wang xiyou.wangcong at gmail.com
Mon Nov 21 02:43:34 EST 2011


On Fri, Nov 18, 2011 at 10:11 AM, Simon Horman <horms at verge.net.au> wrote:
> On Wed, Nov 16, 2011 at 09:09:26PM +0800, WANG Cong wrote:
>> 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 at gmail.com>
>>
>> ---
>> diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
>> index 98cda72..333f6ba 100644
>> --- a/kexec/arch/i386/crashdump-x86.c
>> +++ b/kexec/arch/i386/crashdump-x86.c
>> @@ -589,20 +589,18 @@ 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];
>
> I wonder if the following might reduce memory usage:
>
>        const char *crash_notes = "/sys/kernel/crash_notes";

Yeah, sure. Below is the new patch.
-------------------->

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 at gmail.com>
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kexec-tools-fix-get_crash_notes.diff
Type: text/x-patch
Size: 893 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kexec/attachments/20111121/c2d8c7d7/attachment.bin>


More information about the kexec mailing list