diff mbox series

[-next] NFSv4.1 Use kmemdup_nul() helper

Message ID 20220113134317.3130643-1-yangyingliang@huawei.com (mailing list archive)
State New
Headers show
Series [-next] NFSv4.1 Use kmemdup_nul() helper | expand

Commit Message

Yang Yingliang Jan. 13, 2022, 1:43 p.m. UTC
Use kmemdup_nul() helper instead of open-coding to
simplify the code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 fs/nfs/nfs4proc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index e6b49d6318bc..60fcd98b40a6 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4004,11 +4004,10 @@  static void test_fs_location_for_trunking(struct nfs4_fs_location *location,
 			return;
 		xprt_args.dstaddr = &addr;
 		xprt_args.addrlen = addrlen;
-		servername = kmalloc(srv_loc->len + 1, GFP_KERNEL);
+		servername = kmemdup_nul(srv_loc->data, srv_loc->len,
+					 GFP_KERNEL);
 		if (!servername)
 			return;
-		memcpy(servername, srv_loc->data, srv_loc->len);
-		servername[srv_loc->len] = '\0';
 		xprt_args.servername = servername;
 
 		xprtdata.cred = nfs4_get_clid_cred(clp);