* [PATCH] thunderbolt: Use kmemdup instead of kzmalloc and memcpy
@ 2020-12-23 1:26 Tian Tao
2020-12-28 9:46 ` Mika Westerberg
0 siblings, 1 reply; 2+ messages in thread
From: Tian Tao @ 2020-12-23 1:26 UTC (permalink / raw)
To: isaac.hazan, andreas.noever, michael.jamet, mika.westerberg, YehezkelShB
Cc: linux-usb
Fixes coccicheck warning:
drivers/thunderbolt/dma_test.c:302:13-20: WARNING opportunity for kmemdup.
Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
drivers/thunderbolt/dma_test.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/thunderbolt/dma_test.c b/drivers/thunderbolt/dma_test.c
index f924423..955f980 100644
--- a/drivers/thunderbolt/dma_test.c
+++ b/drivers/thunderbolt/dma_test.c
@@ -299,14 +299,12 @@ static int dma_test_submit_tx(struct dma_test *dt, size_t npackets)
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)) {
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] thunderbolt: Use kmemdup instead of kzmalloc and memcpy
2020-12-23 1:26 [PATCH] thunderbolt: Use kmemdup instead of kzmalloc and memcpy Tian Tao
@ 2020-12-28 9:46 ` Mika Westerberg
0 siblings, 0 replies; 2+ messages in thread
From: Mika Westerberg @ 2020-12-28 9:46 UTC (permalink / raw)
To: Tian Tao
Cc: isaac.hazan, andreas.noever, michael.jamet, YehezkelShB, linux-usb
On Wed, Dec 23, 2020 at 09:26:33AM +0800, Tian Tao wrote:
> Fixes coccicheck warning:
> drivers/thunderbolt/dma_test.c:302:13-20: WARNING opportunity for kmemdup.
>
> Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-28 9:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23 1:26 [PATCH] thunderbolt: Use kmemdup instead of kzmalloc and memcpy Tian Tao
2020-12-28 9:46 ` Mika Westerberg
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.