[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1638434037-44171-1-git-send-email-jiapeng.chong@linux.alibaba.com>
Date: Thu, 2 Dec 2021 16:33:57 +0800
From: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
To: davem@...emloft.net
Cc: kuba@...nel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Subject: [PATCH] net: mpls: use kmemdup() to replace kmalloc + memcpy
Eliminate the follow coccicheck warning:
./net/mpls/af_mpls.c:1530:9-16: WARNING opportunity for kmemdup.
Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
---
net/mpls/af_mpls.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
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);
}
}
--
1.8.3.1
Powered by blists - more mailing lists