Skip to content

Commit

Permalink
net: mpls: fix memdup.cocci warning
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20220406114629.182833-1-gongruiqi1@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
GONG, Ruiqi authored and Jakub Kicinski committed Apr 8, 2022
1 parent 26894cd commit 27a5a56
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/mpls/af_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 27a5a56

Please sign in to comment.