Commit 09bb8986 authored by Chen Zhou's avatar Chen Zhou Committed by Christoph Hellwig

nvmet: replace kstrndup() with kmemdup_nul()

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: default avatarChen Zhou <chenzhou10@huawei.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 263c6158
...@@ -324,7 +324,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item, ...@@ -324,7 +324,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
kfree(ns->device_path); kfree(ns->device_path);
ret = -ENOMEM; ret = -ENOMEM;
ns->device_path = kstrndup(page, len, GFP_KERNEL); ns->device_path = kmemdup_nul(page, len, GFP_KERNEL);
if (!ns->device_path) if (!ns->device_path)
goto out_unlock; goto out_unlock;
...@@ -960,7 +960,7 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item, ...@@ -960,7 +960,7 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
return -EINVAL; return -EINVAL;
} }
new_model_number = kstrndup(page, len, GFP_KERNEL); new_model_number = kmemdup_nul(page, len, GFP_KERNEL);
if (!new_model_number) if (!new_model_number)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
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