<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From dd6cc798ea40a00b256bb9d0b2d9ce185b53c009 Mon Sep 17 00:00:00 2001
From: Thomas Meyer &lt;thomas@m3y3r.de&gt;
Date: Sat, 12 Nov 2011 13:21:49 +0100
Subject: [PATCH 29/70] staging: hv: Use kmemdup rather than duplicating its
 implementation

Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Thomas Meyer &lt;thomas@m3y3r.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
(cherry picked from commit 27b7923035f737a7e6384d0084e34706ea068040)

Signed-off-by: Tim Gardner &lt;tim.gardner@canonical.com&gt;
---
 drivers/staging/hv/hv_mouse.c |    4 +---
 drivers/staging/hv/netvsc.c   |   11 +++--------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 2c2e1b4..a28c549 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -201,13 +201,11 @@ static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
 	desc = &amp;device_info-&gt;hid_descriptor;
 	WARN_ON(desc-&gt;bLength == 0);
 
-	input_device-&gt;hid_desc = kzalloc(desc-&gt;bLength, GFP_ATOMIC);
+	input_device-&gt;hid_desc = kmemdup(desc, desc-&gt;bLength, GFP_ATOMIC);
 
 	if (!input_device-&gt;hid_desc)
 		goto cleanup;
 
-	memcpy(input_device-&gt;hid_desc, desc, desc-&gt;bLength);
-
 	input_device-&gt;report_desc_size = desc-&gt;desc[0].wDescriptorLength;
 	if (input_device-&gt;report_desc_size == 0)
 		goto cleanup;
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index b902579..28e69a6 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -230,19 +230,14 @@ static int netvsc_init_recv_buf(struct hv_device *device)
 	net_device-&gt;recv_section_cnt = init_packet-&gt;msg.
 		v1_msg.send_recv_buf_complete.num_sections;
 
-	net_device-&gt;recv_section = kmalloc(net_device-&gt;recv_section_cnt
-		* sizeof(struct nvsp_1_receive_buffer_section), GFP_KERNEL);
+	net_device-&gt;recv_section = kmemdup(init_packet-&gt;msg.v1_msg.send_recv_buf_complete.sections,
+					   net_device-&gt;recv_section_cnt * sizeof(struct nvsp_1_receive_buffer_section),
+					   GFP_KERNEL);
 	if (net_device-&gt;recv_section == NULL) {
 		ret = -EINVAL;
 		goto cleanup;
 	}
 
-	memcpy(net_device-&gt;recv_section,
-		init_packet-&gt;msg.v1_msg.
-	       send_recv_buf_complete.sections,
-		net_device-&gt;recv_section_cnt *
-	       sizeof(struct nvsp_1_receive_buffer_section));
-
 	/*
 	 * For 1st release, there should only be 1 section that represents the
 	 * entire receive buffer
-- 
1.7.9

</pre></body></html>