mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
@ 2021-05-23  7:56 YueHaibing
  2021-05-23 13:29 ` Christophe Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: YueHaibing @ 2021-05-23  7:56 UTC (permalink / raw)
  To: leoyang.li, davem, kuba, rasmus.villemoes
  Cc: netdev, linuxppc-dev, linux-kernel, YueHaibing

Issue identified with Coccinelle.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/freescale/ucc_geth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index e0936510fa34..51206272cc25 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3590,10 +3590,10 @@ static int ucc_geth_probe(struct platform_device* ofdev)
 	if ((ucc_num < 0) || (ucc_num > 7))
 		return -ENODEV;
 
-	ug_info = kmalloc(sizeof(*ug_info), GFP_KERNEL);
+	ug_info = kmemdup(&ugeth_primary_info, sizeof(*ug_info),
+			  GFP_KERNEL);
 	if (ug_info == NULL)
 		return -ENOMEM;
-	memcpy(ug_info, &ugeth_primary_info, sizeof(*ug_info));
 
 	ug_info->uf_info.ucc_num = ucc_num;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-24  1:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-23  7:56 [PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy YueHaibing
2021-05-23 13:29 ` Christophe Leroy
2021-05-23 14:26   ` Andrew Lunn
2021-05-24  1:07     ` YueHaibing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®