summaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2018-06-11 15:47:21 +0200
committerDan Williams <dan.j.williams@intel.com>2018-12-11 00:58:46 +0100
commit3d9cbe37c16ffd19eeab6b49a0311bbb999627d8 (patch)
tree39d06daf02f50b4d896227790a4df77cde1781d6 /drivers/nvdimm
parentlibnvdimm, label: Switch to bitmap_zalloc() (diff)
downloadlinux-3d9cbe37c16ffd19eeab6b49a0311bbb999627d8.tar.xz
linux-3d9cbe37c16ffd19eeab6b49a0311bbb999627d8.zip
libnvdimm, namespace: Replace kmemdup() with kstrndup()
kstrndup() takes care of '\0' terminator for the strings. Use it here instead of kmemdup() + explicit terminating the input string. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm')
-rw-r--r--drivers/nvdimm/namespace_devs.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 681af3a8fd62..4b077555ac70 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -270,11 +270,10 @@ static ssize_t __alt_name_store(struct device *dev, const char *buf,
if (dev->driver || to_ndns(dev)->claim)
return -EBUSY;
- input = kmemdup(buf, len + 1, GFP_KERNEL);
+ input = kstrndup(buf, len, GFP_KERNEL);
if (!input)
return -ENOMEM;
- input[len] = '\0';
pos = strim(input);
if (strlen(pos) + 1 > NSLABEL_NAME_LEN) {
rc = -EINVAL;