[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220323080706.212531-1-gongruiqi1@huawei.com>
Date: Wed, 23 Mar 2022 16:07:06 +0800
From: "GONG, Ruiqi" <gongruiqi1@...wei.com>
To: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
CC: Benjamin Poirier <bpoirier@...dia.com>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
Wang Weiyang <wangweiyang2@...wei.com>,
"Xiu Jianfeng" <xiujianfeng@...wei.com>
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
Fixes: 7d4741eacdef ("net: mpls: Fix notifications when deleting a device")
Signed-off-by: GONG, Ruiqi <gongruiqi1@...wei.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
Powered by blists - more mailing lists