Commit 27a5a568 authored by GONG, Ruiqi's avatar GONG, Ruiqi Committed by Jakub Kicinski

net: mpls: fix memdup.cocci warning

Simply use kmemdup instead of explicitly allocating and copying memory.

Generated by: scripts/coccinelle/api/memdup.cocci
Signed-off-by: default avatarGONG, Ruiqi <gongruiqi1@huawei.com>
Link: https://lore.kernel.org/r/20220406114629.182833-1-gongruiqi1@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 26894cd9
...@@ -1527,10 +1527,9 @@ static int mpls_ifdown(struct net_device *dev, int event) ...@@ -1527,10 +1527,9 @@ static int mpls_ifdown(struct net_device *dev, int event)
rt->rt_nh_size; rt->rt_nh_size;
struct mpls_route *orig = rt; struct mpls_route *orig = rt;
rt = kmalloc(size, GFP_KERNEL); rt = kmemdup(orig, size, GFP_KERNEL);
if (!rt) if (!rt)
return -ENOMEM; return -ENOMEM;
memcpy(rt, orig, size);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment