diff mbox series

[-next] HID: thrustmaster: Switch to kmemdup() when allocate change_request

Message ID 20210511113033.3760555-1-yangyingliang@huawei.com
State Accepted
Commit 3b770932eefb7c0c6319d332023efee87eb12913
Headers show
Series [-next] HID: thrustmaster: Switch to kmemdup() when allocate change_request | expand

Commit Message

Yang Yingliang May 11, 2021, 11:30 a.m. UTC
Use kmemdup() helper instead of open-coding to
simplify the code when allocate change_request.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hid/hid-thrustmaster.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jiri Kosina June 25, 2021, 12:11 p.m. UTC | #1
On Tue, 11 May 2021, Yang Yingliang wrote:

> Use kmemdup() helper instead of open-coding to

> simplify the code when allocate change_request.

> 

> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>


Applied, thanks.

-- 
Jiri Kosina
SUSE Labs
diff mbox series

Patch

diff --git a/drivers/hid/hid-thrustmaster.c b/drivers/hid/hid-thrustmaster.c
index f643b1cb112d..cdc7d82ae9ed 100644
--- a/drivers/hid/hid-thrustmaster.c
+++ b/drivers/hid/hid-thrustmaster.c
@@ -311,12 +311,13 @@  static int thrustmaster_probe(struct hid_device *hdev, const struct hid_device_i
 		goto error4;
 	}
 
-	tm_wheel->change_request = kzalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
+	tm_wheel->change_request = kmemdup(&change_request,
+					   sizeof(struct usb_ctrlrequest),
+					   GFP_KERNEL);
 	if (!tm_wheel->change_request) {
 		ret = -ENOMEM;
 		goto error5;
 	}
-	memcpy(tm_wheel->change_request, &change_request, sizeof(struct usb_ctrlrequest));
 
 	tm_wheel->usb_dev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));
 	hid_set_drvdata(hdev, tm_wheel);