Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1202410 > unrolled thread

[PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation

Started byAndrzej Hajda <a.hajda@samsung.com>
First post2015-08-07 10:10 +0200
Last post2015-08-07 18:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating  its implementation Andrzej Hajda <a.hajda@samsung.com> - 2015-08-07 10:10 +0200
    Re: [PATCH 07/31] arch/x86/microcode: use kmemdup rather than  duplicating its implementation Borislav Petkov <bp@alien8.de> - 2015-08-07 18:40 +0200

#1202410 — [PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation

FromAndrzej Hajda <a.hajda@samsung.com>
Date2015-08-07 10:10 +0200
Subject[PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation
Message-ID<pUKT0-21E-19@gated-at.bofh.it>
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 <a.hajda@samsung.com>
---
 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/

[toc] | [next] | [standalone]


#1202886 — Re: [PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation

FromBorislav Petkov <bp@alien8.de>
Date2015-08-07 18:40 +0200
SubjectRe: [PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation
Message-ID<pUSQx-52p-15@gated-at.bofh.it>
In reply to#1202410
On Fri, Aug 07, 2015 at 09:59:13AM +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

I dropped this footnote from the commit message as it seems that your
fix is going to be integrated into memdup.cocci.

> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  arch/x86/kernel/cpu/microcode/amd.c         | 4 +---
>  arch/x86/kernel/cpu/microcode/intel_early.c | 4 +---
>  2 files changed, 2 insertions(+), 6 deletions(-)

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web