aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuang Zijiang <[email protected]>2019-01-12 15:16:24 +0800
committerBorislav Petkov <[email protected]>2019-01-13 15:11:35 +0100
commit345dca4ca7e65a46bf0b6e2e6b8ab2e998ec6e91 (patch)
treeabe535b4813151d4fcb6430812332fe2fa4a9116
parentbfeffd155283772bbe78c6a05dec7c0128ee500c (diff)
x86/e820: Replace kmalloc() + memcpy() with kmemdup()
Use the equivalent kmemdup() directly instead of kmalloc() + memcpy(). No functional changes. [ bp: rewrite commit message. ] Signed-off-by: Huang Zijiang <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: Andrew Morton <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Joe Perches <[email protected]> Cc: [email protected] Cc: Masayoshi Mizuma <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
-rw-r--r--arch/x86/kernel/e820.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 50895c2f937d..a687d10da417 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -671,21 +671,18 @@ __init void e820__reallocate_tables(void)
int size;
size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry)*e820_table->nr_entries;
- n = kmalloc(size, GFP_KERNEL);
+ n = kmemdup(e820_table, size, GFP_KERNEL);
BUG_ON(!n);
- memcpy(n, e820_table, size);
e820_table = n;
size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry)*e820_table_kexec->nr_entries;
- n = kmalloc(size, GFP_KERNEL);
+ n = kmemdup(e820_table_kexec, size, GFP_KERNEL);
BUG_ON(!n);
- memcpy(n, e820_table_kexec, size);
e820_table_kexec = n;
size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry)*e820_table_firmware->nr_entries;
- n = kmalloc(size, GFP_KERNEL);
+ n = kmemdup(e820_table_firmware, size, GFP_KERNEL);
BUG_ON(!n);
- memcpy(n, e820_table_firmware, size);
e820_table_firmware = n;
}