Message ID | 1638434037-44171-1-git-send-email-jiapeng.chong@linux.alibaba.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: mpls: use kmemdup() to replace kmalloc + memcpy | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 48f75a5..38c8a1f 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -1527,10 +1527,9 @@ static int mpls_ifdown(struct net_device *dev, int event) rt->rt_nh_size; struct mpls_route *orig = rt; - rt = kmalloc(size, GFP_KERNEL); + rt = kmemdup(orig, size, GFP_KERNEL); if (!rt) return -ENOMEM; - memcpy(rt, orig, size); } }
Eliminate the follow coccicheck warning: ./net/mpls/af_mpls.c:1530:9-16: WARNING opportunity for kmemdup. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> --- net/mpls/af_mpls.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)