ethernet: ucc_geth: Use kmemdup instead of kmalloc and memcpy
PATCH 1/1 ethernet: ucc_geth: Use kmemdup instead of kmalloc and memcpy
From: Junlin Yang <[email protected]>
Fixes coccicheck warnings:
./drivers/net/ethernet/freescale/ucc_geth.c:3594:11-18:
WARNING opportunity for kmemdup
Signed-off-by Junlin Yang <[email protected]>
--- drivers/net/ethernet/freescale/ucc_geth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/freescale/ucc_geth.c +1 -2
@@ -3591,10 +3591,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;
Signature · 1 line
1.9.1
Quoted 18 lines · angkery
From: Junlin Yang <[email protected]>
Fixes coccicheck warnings:
./drivers/net/ethernet/freescale/ucc_geth.c:3594:11-18:
WARNING opportunity for kmemdupSigned-off-by Junlin Yang <[email protected]>--- drivers/net/ethernet/freescale/ucc_geth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ethernet/freescale/ucc_geth.c +0
-0@@ -3591,10 +3591,9 @@ static int ucc_geth_probe(struct platform_device* ofdev)if ((ucc_num <0 ) || (ucc_num >7 ))
drivers/net/ethernet/freescale/ucc_geth.c static int ucc_geth_probe(struct platform_device* ofdev) · line 3599
Quoted 10 lines
drivers/net/ethernet/freescale/ucc_geth.c +1
-2return -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;
Ah, yes, of course, I should have used that.
Acked-by Rasmus Villemoes <[email protected]>