Use kmemdup() helper instead of open-coding to
simplify the code when allocate change_request.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
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);