All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: [PATCH] thunderbolt: fix memdup.cocci warnings
Date: Fri, 11 Dec 2020 02:48:07 +0800	[thread overview]
Message-ID: <20201210184807.GA67701@65edf73b2f88> (raw)
In-Reply-To: <202012110258.aT678X1X-lkp@intel.com>

[-- Attachment #1: Type: text/plain, Size: 1959 bytes --]

CC: kbuild-all(a)lists.01.org
CC: Linux Memory Management List <linux-mm@kvack.org>
TO: Isaac Hazan <isaac.hazan@intel.com>
CC: Mika Westerberg <mika.westerberg@linux.intel.com>
CC: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
CC: Andreas Noever <andreas.noever@gmail.com>
CC: Michael Jamet <michael.jamet@intel.com>
CC: Yehezkel Bernat <YehezkelShB@gmail.com>
CC: linux-usb(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

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

drivers/thunderbolt/dma_test.c:302:13-20: WARNING opportunity for kmemdup

 Use kmemdup rather than duplicating its implementation

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

Fixes: edc0f494ed96 ("thunderbolt: Add DMA traffic test driver")
CC: Isaac Hazan <isaac.hazan@intel.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:   14240d4c5b25d087529691ccf4d7ea256f26cfdf
commit: edc0f494ed966e39e5619be7cdaeb9873e1f4fe1 [3860/12554] thunderbolt: Add DMA traffic test driver
:::::: branch date: 9 hours ago
:::::: commit date: 4 weeks ago

Please take the patch only if it's a positive warning. Thanks!

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

--- a/drivers/thunderbolt/dma_test.c
+++ b/drivers/thunderbolt/dma_test.c
@@ -299,14 +299,13 @@ static int dma_test_submit_tx(struct dma
 		tf->frame.size = 0; /* means 4096 */
 		tf->dma_test = dt;
 
-		tf->data = kzalloc(DMA_TEST_FRAME_SIZE, GFP_KERNEL);
+		tf->data = kmemdup(dma_test_pattern, DMA_TEST_FRAME_SIZE,
+				   GFP_KERNEL);
 		if (!tf->data) {
 			kfree(tf);
 			return -ENOMEM;
 		}
 
-		memcpy(tf->data, dma_test_pattern, DMA_TEST_FRAME_SIZE);
-
 		dma_addr = dma_map_single(dma_dev, tf->data, DMA_TEST_FRAME_SIZE,
 					  DMA_TO_DEVICE);
 		if (dma_mapping_error(dma_dev, dma_addr)) {

      reply	other threads:[~2020-12-10 18:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 18:48 [linux-next:master 3860/12554] drivers/thunderbolt/dma_test.c:302:13-20: WARNING opportunity for kmemdup kernel test robot
2020-12-10 18:48 ` kernel test robot [this message]

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=20201210184807.GA67701@65edf73b2f88 \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.