From: tip-bot for Andrzej Hajda <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: b.zolnierkie@samsung.com, peterz@infradead.org,
torvalds@linux-foundation.org, hpa@zytor.com,
a.hajda@samsung.com, bp@suse.de, tglx@linutronix.de,
m.szyprowski@samsung.com, mingo@kernel.org,
linux-kernel@vger.kernel.org
Subject: [tip:x86/microcode] x86/microcode: Use kmemdup() rather than duplicating its implementation
Date: Wed, 17 Feb 2016 04:12:38 -0800 [thread overview]
Message-ID: <tip-9cc6f743c7724eb9abaf27904194c169db85dd31@git.kernel.org> (raw)
In-Reply-To: <1455612202-14414-3-git-send-email-bp@alien8.de>
Commit-ID: 9cc6f743c7724eb9abaf27904194c169db85dd31
Gitweb: http://git.kernel.org/tip/9cc6f743c7724eb9abaf27904194c169db85dd31
Author: Andrzej Hajda <a.hajda@samsung.com>
AuthorDate: Tue, 16 Feb 2016 09:43:20 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 17 Feb 2016 08:46:08 +0100
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@samsung.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1455612202-14414-3-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/cpu/microcode/amd.c | 4 +---
arch/x86/kernel/cpu/microcode/intel.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 f66cbfe..e397fc1 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -788,15 +788,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.c b/arch/x86/kernel/cpu/microcode/intel.c
index cb397947..cbb3cf0 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -210,13 +210,11 @@ save_microcode(struct mc_saved_data *mcs,
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);
}
/*
next prev parent reply other threads:[~2016-02-17 12:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 8:43 [PATCH 0/4] tip-queue 2016-02-16 Borislav Petkov
2016-02-16 8:43 ` [PATCH 1/4] x86/microcode: Remove unnecessary paravirt_enabled check Borislav Petkov
2016-02-17 12:12 ` [tip:x86/microcode] " tip-bot for Boris Ostrovsky
2016-02-16 8:43 ` [PATCH 2/4] x86/microcode: Use kmemdup() rather than duplicating its implementation Borislav Petkov
2016-02-17 12:12 ` tip-bot for Andrzej Hajda [this message]
2016-02-16 8:43 ` [PATCH 3/4] ftrace: Kill ftrace_caller_end label Borislav Petkov
2016-02-17 12:13 ` [tip:x86/asm] x86/ftrace, x86/asm: " tip-bot for Borislav Petkov
2016-02-16 8:43 ` [PATCH 4/4] x86/msr: Document msr-index.h rule for addition Borislav Petkov
2016-02-17 12:13 ` [tip:x86/asm] " tip-bot for Borislav Petkov
-- strict thread matches above, loose matches on Subject: below --
2015-08-10 10:19 [PATCH 1/3] x86/microcode: Use kmemdup() rather than duplicating its implementation Borislav Petkov
2015-08-22 13:58 ` [tip:x86/microcode] " tip-bot for Andrzej Hajda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-9cc6f743c7724eb9abaf27904194c169db85dd31@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.hajda@samsung.com \
--cc=b.zolnierkie@samsung.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox