lkml.org 
[lkml]   [2014]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 1/2] efi: Fix krealloc defect
On Fri, 03 Jan, at 04:08:47PM, Joe Perches wrote:
> 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(-)

Thanks Joe, but I've already got the following commit queued up from
Borislav that addresses this,

---

From ee41143027706d9f342dfe05487a00b20887fde7 Mon Sep 17 00:00:00 2001
From: Borislav Petkov <bp@suse.de>
Date: Thu, 31 Oct 2013 17:25:09 +0100
Subject: [PATCH] x86/efi: Check krealloc return value

Check it just in case. We might just as well panic there because runtime
won't be functioning anyway.

Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
arch/x86/platform/efi/efi.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index b453069236fd..3fac4dee492f 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -860,6 +860,9 @@ void __init efi_enter_virtual_mode(void)
new_memmap = krealloc(new_memmap,
(count + 1) * memmap.desc_size,
GFP_KERNEL);
+ if (!new_memmap)
+ goto err_out;
+
memcpy(new_memmap + (count * memmap.desc_size), md,
memmap.desc_size);
count++;
@@ -914,6 +917,11 @@ void __init efi_enter_virtual_mode(void)
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL);
+
+ return;
+
+ err_out:
+ pr_err("Error reallocating memory, EFI runtime non-functional!\n");
}

/*
--
1.8.3.1
--
Matt Fleming, Intel Open Source Technology Center


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