From: YueHaibing Date: Mon, 24 May 2021 01:07:01 +0000 (+0800) Subject: ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy X-Git-Tag: v5.15~843^2~466 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec7d6dd870d421a853ffa692d4bce5783a519342;p=platform%2Fkernel%2Flinux-starfive.git ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy Issue identified with Coccinelle. Signed-off-by: YueHaibing Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index e093651..0acfafb 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -3590,10 +3590,9 @@ 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;