Skip to contentSkip to conversation

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

PATCH kernel test robot 1 participant 2 messages Dec 10, 2020

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

CC: kbuild-all(a)lists.01.org
CC: Linux Memory Management List <[email protected]>
TO: Isaac Hazan <[email protected]>
CC: Mika Westerberg <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>

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
config: microblaze-randconfig-c003-20201210 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

"coccinelle warnings: (new ones prefixed by >>)"

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

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author build bot
#1 lore raw

[PATCH] thunderbolt: fix memdup.cocci warnings

CC: kbuild-all(a)lists.01.org CC: Linux Memory Management List <[email protected]> TO: Isaac Hazan <[email protected]> CC: Mika Westerberg <[email protected]> CC: "Greg…

CC: kbuild-all(a)lists.01.org
CC: Linux Memory Management List <[email protected]>
TO: Isaac Hazan <[email protected]>
CC: Mika Westerberg <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>
CC: Andreas Noever <[email protected]>
CC: Michael Jamet <[email protected]>
CC: Yehezkel Bernat <[email protected]>
CC: linux-usb(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

From: kernel test robot <[email protected]>

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 <[email protected]>

---

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(-)
drivers/thunderbolt/dma_test.c +2 -3
@@ -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)) {