diff mbox series

net: mpls: fix memdup.cocci warning

Message ID 20220323080706.212531-1-gongruiqi1@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: mpls: fix memdup.cocci warning | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

GONG Ruiqi March 23, 2022, 8:07 a.m. UTC
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(-)

Comments

Jakub Kicinski March 23, 2022, 3:48 p.m. UTC | #1
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.
diff mbox series

Patch

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);
 			}
 		}