From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-nfs@vger.kernel.org>
Cc: <anna.schumaker@netapp.com>, <trond.myklebust@hammerspace.com>
Subject: [PATCH -next] NFSv4.1 Use kmemdup_nul() helper
Date: Thu, 13 Jan 2022 21:43:17 +0800 [thread overview]
Message-ID: <20220113134317.3130643-1-yangyingliang@huawei.com> (raw)
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 --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
reply other threads:[~2022-01-13 13:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220113134317.3130643-1-yangyingliang@huawei.com \
--to=yangyingliang@huawei.com \
--cc=anna.schumaker@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®