2022-04-06 16:48:26

by GONG, Ruiqi

[permalink] [raw]
Subject: [PATCH] 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: GONG, Ruiqi <[email protected]>
---
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


2022-04-08 04:54:04

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] net: mpls: fix memdup.cocci warning

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <[email protected]>:

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 <[email protected]>
> ---
> 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