Commit 66ff8994 authored by kernel test robot's avatar kernel test robot Committed by Jiri Kosina

HID: fix memdup.cocci warnings

drivers/hid/hid-thrustmaster.c:300:27-34: WARNING opportunity for kmemdup

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: c49c3363 ("HID: support for initialization of some Thrustmaster wheels")
CC: Dario Pagani <dario.pagani.146@gmail.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent dfe74f55
...@@ -297,12 +297,13 @@ static int thrustmaster_probe(struct hid_device *hdev, const struct hid_device_i ...@@ -297,12 +297,13 @@ static int thrustmaster_probe(struct hid_device *hdev, const struct hid_device_i
goto error2; goto error2;
} }
tm_wheel->model_request = kzalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); tm_wheel->model_request = kmemdup(&model_request,
sizeof(struct usb_ctrlrequest),
GFP_KERNEL);
if (!tm_wheel->model_request) { if (!tm_wheel->model_request) {
ret = -ENOMEM; ret = -ENOMEM;
goto error3; goto error3;
} }
memcpy(tm_wheel->model_request, &model_request, sizeof(struct usb_ctrlrequest));
tm_wheel->response = kzalloc(sizeof(struct tm_wheel_response), GFP_KERNEL); tm_wheel->response = kzalloc(sizeof(struct tm_wheel_response), GFP_KERNEL);
if (!tm_wheel->response) { if (!tm_wheel->response) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment