mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
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>
This commit is contained in:
parent
9065ed1281
commit
3d9cbe37c1
@ -270,11 +270,10 @@ static ssize_t __alt_name_store(struct device *dev, const char *buf,
|
|||||||
if (dev->driver || to_ndns(dev)->claim)
|
if (dev->driver || to_ndns(dev)->claim)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
input = kmemdup(buf, len + 1, GFP_KERNEL);
|
input = kstrndup(buf, len, GFP_KERNEL);
|
||||||
if (!input)
|
if (!input)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
input[len] = '\0';
|
|
||||||
pos = strim(input);
|
pos = strim(input);
|
||||||
if (strlen(pos) + 1 > NSLABEL_NAME_LEN) {
|
if (strlen(pos) + 1 > NSLABEL_NAME_LEN) {
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user