HID: thrustmaster: Switch to kmemdup() when allocate change_request
PATCH 1/1 HID: thrustmaster: Switch to kmemdup() when allocate change_request
Use kmemdup() helper instead of open-coding to
simplify the code when allocate change_request.
Signed-off-by Yang Yingliang <[email protected]>
--- drivers/hid/hid-thrustmaster.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hid/hid-thrustmaster.c +3 -2
@@ -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);
Signature · 1 line
2.25.1
Quoted 4 lines · Yang Yingliang
Use
kmemdup()helper instead of open-coding to
simplify the code when allocatechange_request.Signed-off-by Yang Yingliang <[email protected]>
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs