Commit 27a5a568 authored by GONG, Ruiqi's avatar GONG, Ruiqi Committed by Jakub Kicinski
Browse files

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: default avatarGONG, Ruiqi <gongruiqi1@huawei.com>
Link: https://lore.kernel.org/r/20220406114629.182833-1-gongruiqi1@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 26894cd9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
			}
		}