Commit 3d9cbe37 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Dan Williams
Browse files

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: default avatarAndy Shevchenko <>
Signed-off-by: default avatarDave Jiang <>
Signed-off-by: default avatarDan Williams <>
parent 9065ed12
......@@ -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;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment