1
0
Fork 0

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 <huang.zijiang@zte.com.cn>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: jschoenh@amazon.de
Cc: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Cc: xue.zhihong@zte.com.cn
Link: https://lkml.kernel.org/r/1547277384-22156-1-git-send-email-wang.yi59@zte.com.cn
hifive-unleashed-5.1
Huang Zijiang 2019-01-12 15:16:24 +08:00 committed by Borislav Petkov
parent bfeffd1552
commit 345dca4ca7
1 changed files with 3 additions and 6 deletions

View File

@ -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;
}