From: Chen Zhou <chenzhou10@huawei.com>
To: <kishon@ti.com>, <lorenzo.pieralisi@arm.com>, <bhelgaas@google.com>
Cc: <linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chenzhou10@huawei.com>
Subject: [PATCH -next] PCI: endpoint: use kmemdup_nul() in pci_epf_create()
Date: Fri, 8 May 2020 20:10:29 +0800 [thread overview]
Message-ID: <20200508121029.167018-1-chenzhou10@huawei.com> (raw)
It is more efficient to use kmemdup_nul() if the size is known exactly.
The doc in kernel:
"Note: Use kmemdup_nul() instead if the size is known exactly."
Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
---
drivers/pci/endpoint/pci-epf-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c
index 244e00f48c5c..f035d2ebcae5 100644
--- a/drivers/pci/endpoint/pci-epf-core.c
+++ b/drivers/pci/endpoint/pci-epf-core.c
@@ -252,7 +252,7 @@ struct pci_epf *pci_epf_create(const char *name)
return ERR_PTR(-ENOMEM);
len = strchrnul(name, '.') - name;
- epf->name = kstrndup(name, len, GFP_KERNEL);
+ epf->name = kmemdup_nul(name, len, GFP_KERNEL);
if (!epf->name) {
kfree(epf);
return ERR_PTR(-ENOMEM);
--
2.20.1
next reply other threads:[~2020-05-08 12:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-08 12:10 Chen Zhou [this message]
2020-05-08 16:23 ` [PATCH -next] PCI: endpoint: use kmemdup_nul() in pci_epf_create() Bjorn Helgaas
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=20200508121029.167018-1-chenzhou10@huawei.com \
--to=chenzhou10@huawei.com \
--cc=bhelgaas@google.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.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