lkml.org 
[lkml]   [2014]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/2] efi: Fix krealloc defect
    Date
    krealloc should use a temporary pointer for allocations
    and check the temporary pointer returned against NULL too.

    Signed-off-by: Joe Perches <joe@perches.com>
    cc: Matthew Garrett <matthew.garrett@nebula.com>
    ---
    arch/x86/platform/efi/efi.c | 12 +++++++++---
    1 file changed, 9 insertions(+), 3 deletions(-)

    diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
    index cceb813..ef7b7b4 100644
    --- a/arch/x86/platform/efi/efi.c
    +++ b/arch/x86/platform/efi/efi.c
    @@ -798,6 +798,8 @@ void __init efi_enter_virtual_mode(void)
    }

    for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
    + void *new_memmap2;
    +
    md = p;
    if (!(md->attribute & EFI_MEMORY_RUNTIME)) {
    #ifdef CONFIG_X86_64
    @@ -834,9 +836,13 @@ void __init efi_enter_virtual_mode(void)
    systab += md->virt_addr - md->phys_addr;
    efi.systab = (efi_system_table_t *) (unsigned long) systab;
    }
    - new_memmap = krealloc(new_memmap,
    - (count + 1) * memmap.desc_size,
    - GFP_KERNEL);
    + new_memmap2 = krealloc(new_memmap,
    + (count + 1) * memmap.desc_size,
    + GFP_KERNEL);
    + if (!new_memmap2)
    + continue;
    +
    + new_memmap = new_memmap2;
    memcpy(new_memmap + (count * memmap.desc_size), md,
    memmap.desc_size);
    count++;
    --
    1.8.1.2.459.gbcd45b4.dirty


    \
     
     \ /
      Last update: 2014-01-04 01:41    [W:3.850 / U:0.104 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site