Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2627934imu; Sun, 13 Jan 2019 06:24:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN6RpCBvxtICPBWNc/KfTI1muZHM6OLTAM57VxuU9ii1pzgCQQBiLyo8WDVmv7paqSrTVi1+ X-Received: by 2002:a63:7418:: with SMTP id p24mr9788864pgc.196.1547389463706; Sun, 13 Jan 2019 06:24:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547389463; cv=none; d=google.com; s=arc-20160816; b=XvgDXqvsDG8Bruxm2KmUSTygSfWb7PZeNbG3+Tc1QxYocpZ9/SCjPwGOHP9x3Mngcc C4vsp500YGw701sdbMCHMU/iFw0PNYNNzRW1jht3wP7Jjy8RkYs6ZxCtGVtdINByMrOc FhJe/IK7NnQES3XDxSvOxp+A22SMqUew2oHTkaQ2tzxSVGbav8eYDFZidbFk8BKeT2Ot 0yX93dr4SCW1kQ5+OP4YFL6L+LE7SemaD/oZaiNDOMk2NlmC/+vscwqSTRIyzMN2IXSN Bf+W5kRrBuUJ46kGKgFAdC+rFmslvCT4MhcnUt+J3CJTNi4b1FELicfe7iSN3khLUfOk 2O4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=cpVg2eyJO6lcrLL3rb2sITJJe+bcQ5/YD5b2/TSBc1k=; b=NMnjJyn9dWO/oxnaq5dU2Uy4MK1nh5CdjSMgU7YgE4vAc4R3OvqaFYTtn2cMDGOHWe NMlZPZ+fAPRensELRlmpnX9ETX2c4MouxTusJOI+z++ScDDryhARdvxXLgfAxh9J0pmp VLXlbiFpZhn1BRrd183dNEuuW8N2lculBjVRwo1BFBzZOV8cmUaMjF7mrsCgETasNLKg PGAxuPDhtJ8m2nMHreuPpjGYOQ8VSQwSnQriERnGtslHfhfxFIehyyOVRXyS9OQz/R2C IMxrv7FY6tYUnUUniL1JRZ04apPAP8QxNF8SvFm2FtKDtKg3jPGyuAqkOKC76mgsgtVq JaSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si17608447plk.260.2019.01.13.06.24.07; Sun, 13 Jan 2019 06:24:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbfAMOXD (ORCPT + 99 others); Sun, 13 Jan 2019 09:23:03 -0500 Received: from terminus.zytor.com ([198.137.202.136]:36987 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbfAMOXD (ORCPT ); Sun, 13 Jan 2019 09:23:03 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x0DELvKM1627836 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 13 Jan 2019 06:21:57 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x0DELtlN1627833; Sun, 13 Jan 2019 06:21:55 -0800 Date: Sun, 13 Jan 2019 06:21:55 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Huang Zijiang Message-ID: Cc: rppt@linux.vnet.ibm.com, m.mizuma@jp.fujitsu.com, linux-kernel@vger.kernel.org, mingo@kernel.org, n-horiguchi@ah.jp.nec.com, hpa@zytor.com, huang.zijiang@zte.com.cn, bp@suse.de, mhocko@suse.com, joe@perches.com, x86@kernel.org, tglx@linutronix.de, akpm@linux-foundation.org, mingo@redhat.com Reply-To: akpm@linux-foundation.org, tglx@linutronix.de, joe@perches.com, x86@kernel.org, mingo@redhat.com, m.mizuma@jp.fujitsu.com, mingo@kernel.org, linux-kernel@vger.kernel.org, rppt@linux.vnet.ibm.com, huang.zijiang@zte.com.cn, hpa@zytor.com, bp@suse.de, mhocko@suse.com, n-horiguchi@ah.jp.nec.com In-Reply-To: <1547277384-22156-1-git-send-email-wang.yi59@zte.com.cn> References: <1547277384-22156-1-git-send-email-wang.yi59@zte.com.cn> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cleanups] x86/e820: Replace kmalloc() + memcpy() with kmemdup() Git-Commit-ID: 345dca4ca7e65a46bf0b6e2e6b8ab2e998ec6e91 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 345dca4ca7e65a46bf0b6e2e6b8ab2e998ec6e91 Gitweb: https://git.kernel.org/tip/345dca4ca7e65a46bf0b6e2e6b8ab2e998ec6e91 Author: Huang Zijiang AuthorDate: Sat, 12 Jan 2019 15:16:24 +0800 Committer: Borislav Petkov CommitDate: Sun, 13 Jan 2019 15:11:35 +0100 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 Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Joe Perches Cc: jschoenh@amazon.de Cc: Masayoshi Mizuma Cc: Michal Hocko Cc: Mike Rapoport Cc: Naoya Horiguchi Cc: Thomas Gleixner Cc: x86-ml Cc: xue.zhihong@zte.com.cn Link: https://lkml.kernel.org/r/1547277384-22156-1-git-send-email-wang.yi59@zte.com.cn --- arch/x86/kernel/e820.c | 9 +++------ 1 file 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; }