Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751540AbbHGIHT (ORCPT ); Fri, 7 Aug 2015 04:07:19 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:28638 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422653AbbHGIAq (ORCPT ); Fri, 7 Aug 2015 04:00:46 -0400 X-AuditID: cbfec7f4-f79c56d0000012ee-50-55c4659c2d7c From: Andrzej Hajda To: Borislav Petkov Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation Date: Fri, 07 Aug 2015 09:59:13 +0200 Message-id: <1438934377-4922-8-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> References: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupiluLIzCtJLcpLzFFi42I5/e/4Fd05qUdCDX4d4rS4te4cq8XGGetZ LT5v+MdmcXnXHDaLtUfuslv82PCY1YHN43trH4vHplWdbB59W1YxenzeJBfAEsVlk5Kak1mW WqRvl8CVsfz/QdaCx7wV++bLNDAe5O5i5OSQEDCRmPv0PDuELSZx4d56ti5GLg4hgaWMEicv zmOHcJqYJF5uW8QIUsUmoCnxd/NNNhBbREBJ4uuiuUwgRcwC+xglHn/7ywySEBZIlni1cj9Y EYuAqsTSfc+ZQGxeASeJ5acb2CDWyUmcPDaZFcTmFHCWWNk9E8wWAqp503eBeQIj7wJGhlWM oqmlyQXFSem5hnrFibnFpXnpesn5uZsYISH0ZQfj4mNWhxgFOBiVeHgT/h0OFWJNLCuuzD3E KMHBrCTC+1AfKMSbklhZlVqUH19UmpNafIhRmoNFSZx37q73IUIC6YklqdmpqQWpRTBZJg5O qQbGxd6d+3lFDe5s4DWpYdJfx3ApyZp3navmq6Z4Vb4VHcF/DX4f5Oy/tv6qzv0HXpOXbXkj u/aZ79GqnQtWC7oecnhzV0670bjtxZyfVbOLvqn4M33Z/6Nn/9q8dTOfie1dcWGt+XOFn816 65bwTv3wjmNnLIvEtgv9ZVuidmyc2bkv34v764uYs0osxRmJhlrMRcWJABj1c7wdAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1954 Lines: 59 The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320 Signed-off-by: Andrzej Hajda --- arch/x86/kernel/cpu/microcode/amd.c | 4 +--- arch/x86/kernel/cpu/microcode/intel_early.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index c7d2415..be37f10 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -366,15 +366,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover) return -EINVAL; } - patch->data = kzalloc(patch_size, GFP_KERNEL); + patch->data = kmemdup(fw + SECTION_HDR_SIZE, patch_size, GFP_KERNEL); if (!patch->data) { pr_err("Patch data allocation failure.\n"); kfree(patch); return -EINVAL; } - /* All looks ok, copy patch... */ - memcpy(patch->data, fw + SECTION_HDR_SIZE, patch_size); INIT_LIST_HEAD(&patch->plist); patch->patch_id = mc_hdr->patch_id; patch->equiv_cpu = proc_id; diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c index 37ea89c..3f843f1 100644 --- a/arch/x86/kernel/cpu/microcode/intel_early.c +++ b/arch/x86/kernel/cpu/microcode/intel_early.c @@ -207,13 +207,11 @@ save_microcode(struct mc_saved_data *mc_saved_data, mc_hdr = &mc->hdr; size = get_totalsize(mc_hdr); - saved_ptr[i] = kmalloc(size, GFP_KERNEL); + saved_ptr[i] = kmemdup(mc, size, GFP_KERNEL); if (!saved_ptr[i]) { ret = -ENOMEM; goto err; } - - memcpy(saved_ptr[i], mc, size); } /* -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/