linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mpls: fix memdup.cocci warning
@ 2022-04-06 11:46 GONG, Ruiqi
  2022-04-08  4:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 4+ messages in thread
From: GONG, Ruiqi @ 2022-04-06 11:46 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Wang Weiyang

Simply use kmemdup instead of explicitly allocating and copying memory.

Generated by: scripts/coccinelle/api/memdup.cocci

Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.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 d6fdc5782d33..35b5f806fdda 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);
 			}
 		}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] net: mpls: fix memdup.cocci warning
@ 2022-03-23  8:07 GONG, Ruiqi
  2022-03-23 15:48 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: GONG, Ruiqi @ 2022-03-23  8:07 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Benjamin Poirier, netdev, linux-kernel, Wang Weiyang, Xiu Jianfeng

Simply use kmemdup instead of explicitly allocating and copying memory.

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: 7d4741eacdef ("net: mpls: Fix notifications when deleting a device")
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.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 d6fdc5782d33..35b5f806fdda 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);
 			}
 		}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-08  4:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 11:46 [PATCH] net: mpls: fix memdup.cocci warning GONG, Ruiqi
2022-04-08  4:20 ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2022-03-23  8:07 GONG, Ruiqi
2022-03-23 15:48 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).