linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] HID: thrustmaster: Switch to kmemdup() when allocate change_request
@ 2021-05-11 11:30 Yang Yingliang
  2021-06-25 12:11 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-05-11 11:30 UTC (permalink / raw)
  To: linux-input, linux-kernel; +Cc: jikos, benjamin.tissoires

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(-)

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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] HID: thrustmaster: Switch to kmemdup() when allocate change_request
  2021-05-11 11:30 [PATCH -next] HID: thrustmaster: Switch to kmemdup() when allocate change_request Yang Yingliang
@ 2021-06-25 12:11 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2021-06-25 12:11 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-input, linux-kernel, benjamin.tissoires

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-25 12:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 11:30 [PATCH -next] HID: thrustmaster: Switch to kmemdup() when allocate change_request Yang Yingliang
2021-06-25 12:11 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).