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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200508121029.167018-1-chenzhou10@huawei.com>
Date:   Fri, 8 May 2020 20:10:29 +0800
From:   Chen Zhou <chenzhou10@...wei.com>
To:     <kishon@...com>, <lorenzo.pieralisi@....com>, <bhelgaas@...gle.com>
CC:     <linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <chenzhou10@...wei.com>
Subject: [PATCH -next] PCI: endpoint: use kmemdup_nul() in pci_epf_create()

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@...wei.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ