lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220113134317.3130643-1-yangyingliang@huawei.com>
Date:   Thu, 13 Jan 2022 21:43:17 +0800
From:   Yang Yingliang <yangyingliang@...wei.com>
To:     <linux-kernel@...r.kernel.org>, <linux-nfs@...r.kernel.org>
CC:     <anna.schumaker@...app.com>, <trond.myklebust@...merspace.com>
Subject: [PATCH -next] NFSv4.1 Use kmemdup_nul() helper

Use kmemdup_nul() helper instead of open-coding to
simplify the code.

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ