[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-d4e963644768b33aa3db7f470c35d74ed78d8354@git.kernel.org>
Date: Sat, 22 Aug 2015 06:58:15 -0700
From: tip-bot for Andrzej Hajda <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: m.szyprowski@...sung.com, mingo@...nel.org,
b.zolnierkie@...sung.com, tglx@...utronix.de, bp@...e.de,
hpa@...or.com, torvalds@...ux-foundation.org,
linux-kernel@...r.kernel.org, a.hajda@...sung.com,
peterz@...radead.org
Subject: [tip:x86/microcode] x86/microcode: Use kmemdup()
rather than duplicating its implementation
Commit-ID: d4e963644768b33aa3db7f470c35d74ed78d8354
Gitweb: http://git.kernel.org/tip/d4e963644768b33aa3db7f470c35d74ed78d8354
Author: Andrzej Hajda <a.hajda@...sung.com>
AuthorDate: Mon, 10 Aug 2015 12:19:52 +0200
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Sat, 22 Aug 2015 14:49:35 +0200
x86/microcode: Use kmemdup() rather than duplicating its implementation
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci.
Signed-off-by: Andrzej Hajda <a.hajda@...sung.com>
Signed-off-by: Borislav Petkov <bp@...e.de>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Marek Szyprowski <m.szyprowski@...sung.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Link: http://lkml.kernel.org/r/1439201994-28067-2-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
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 8187b72..101f0ac 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);
}
/*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists