[PATCH] HID: fix memdup.cocci warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: kernel test robot <lkp@xxxxxxxxx>

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: c49c33637802 ("HID: support for initialization of some Thrustmaster wheels")
CC: Dario Pagani <dario.pagani.146@xxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: kernel test robot <lkp@xxxxxxxxx>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   b4f20b70784aabf97e1727561e775500f6e294c7
commit: c49c33637802a2c6957a78119eb8be3b055dd9e9 [4793/7299] HID: support for initialization of some Thrustmaster wheels

 hid-thrustmaster.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/hid/hid-thrustmaster.c
+++ b/drivers/hid/hid-thrustmaster.c
@@ -297,12 +297,13 @@ static int thrustmaster_probe(struct hid
 		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) {
 		ret = -ENOMEM;
 		goto error3;
 	}
-	memcpy(tm_wheel->model_request, &model_request, sizeof(struct usb_ctrlrequest));
 
 	tm_wheel->response = kzalloc(sizeof(struct tm_wheel_response), GFP_KERNEL);
 	if (!tm_wheel->response) {




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux