From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6925166982536471743==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] thunderbolt: fix memdup.cocci warnings Date: Fri, 11 Dec 2020 02:48:07 +0800 Message-ID: <20201210184807.GA67701@65edf73b2f88> In-Reply-To: <202012110258.aT678X1X-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============6925166982536471743== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: Linux Memory Management List TO: Isaac Hazan CC: Mika Westerberg CC: "Greg Kroah-Hartman" CC: Andreas Noever CC: Michael Jamet CC: Yehezkel Bernat CC: linux-usb(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot 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 Reported-by: kernel test robot Signed-off-by: kernel test robot --- 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 =3D 0; /* means 4096 */ tf->dma_test =3D dt; = - tf->data =3D kzalloc(DMA_TEST_FRAME_SIZE, GFP_KERNEL); + tf->data =3D 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 =3D dma_map_single(dma_dev, tf->data, DMA_TEST_FRAME_SIZE, DMA_TO_DEVICE); if (dma_mapping_error(dma_dev, dma_addr)) { --===============6925166982536471743==--