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

* Re: [PATCH] net: mpls: fix memdup.cocci warning
  2022-04-06 11:46 [PATCH] net: mpls: fix memdup.cocci warning GONG, Ruiqi
@ 2022-04-08  4:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-08  4:20 UTC (permalink / raw)
  To: GONG, Ruiqi; +Cc: davem, kuba, pabeni, netdev, linux-kernel, wangweiyang2

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 6 Apr 2022 19:46:29 +0800 you wrote:
> 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(-)

Here is the summary with links:
  - net: mpls: fix memdup.cocci warning
    https://git.kernel.org/netdev/net-next/c/27a5a5685d37

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

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

On Wed, 23 Mar 2022 16:07:06 +0800 GONG, Ruiqi wrote:
> 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")

Fixes tag are for bugs.

> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>

net-next is closed during the merge window please repost in 2 weeks.

^ permalink raw reply	[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).