linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Dario Pagani <dario.pagani.146@gmail.com>
Cc: kbuild-all@lists.01.org,
	Linux Memory Management List <linux-mm@kvack.org>,
	Jiri Kosina <jkosina@suse.cz>,
	Kim Kuparinen <kimi.h.kuparinen@gmail.com>
Subject: [PATCH] HID: fix memdup.cocci warnings
Date: Thu, 25 Mar 2021 23:49:56 +0800	[thread overview]
Message-ID: <20210325154956.GA35356@f923dd4e708e> (raw)
In-Reply-To: <202103252348.wD7w1qG9-lkp@intel.com>

From: kernel test robot <lkp@intel.com>

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@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---

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


  reply	other threads:[~2021-03-25 15:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 15:49 [linux-next:master 4793/7299] drivers/hid/hid-thrustmaster.c:300:27-34: WARNING opportunity for kmemdup kernel test robot
2021-03-25 15:49 ` kernel test robot [this message]
2021-03-30  7:44   ` [PATCH] HID: fix memdup.cocci warnings Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210325154956.GA35356@f923dd4e708e \
    --to=lkp@intel.com \
    --cc=dario.pagani.146@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=kbuild-all@lists.01.org \
    --cc=kimi.h.kuparinen@gmail.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox