* [PATCH -next] nvmet: replace kstrndup() with kmemdup_nul()
@ 2020-05-08 11:59 ` Chen Zhou
0 siblings, 0 replies; 4+ messages in thread
From: Chen Zhou @ 2020-05-08 11:59 UTC (permalink / raw)
To: hch, sagi, chaitanya.kulkarni; +Cc: linux-nvme, linux-kernel, chenzhou10
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@huawei.com>
---
drivers/nvme/target/configfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 58cabd7b6fc5..9894668a40e7 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -327,7 +327,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
kfree(ns->device_path);
ret = -ENOMEM;
- ns->device_path = kstrndup(page, len, GFP_KERNEL);
+ ns->device_path = kmemdup_nul(page, len, GFP_KERNEL);
if (!ns->device_path)
goto out_unlock;
@@ -963,7 +963,7 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
return -EINVAL;
}
- new_model_number = kstrndup(page, len, GFP_KERNEL);
+ new_model_number = kmemdup_nul(page, len, GFP_KERNEL);
if (!new_model_number)
return -ENOMEM;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH -next] nvmet: replace kstrndup() with kmemdup_nul()
@ 2020-05-08 11:59 ` Chen Zhou
0 siblings, 0 replies; 4+ messages in thread
From: Chen Zhou @ 2020-05-08 11:59 UTC (permalink / raw)
To: hch, sagi, chaitanya.kulkarni; +Cc: chenzhou10, linux-kernel, linux-nvme
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@huawei.com>
---
drivers/nvme/target/configfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 58cabd7b6fc5..9894668a40e7 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -327,7 +327,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
kfree(ns->device_path);
ret = -ENOMEM;
- ns->device_path = kstrndup(page, len, GFP_KERNEL);
+ ns->device_path = kmemdup_nul(page, len, GFP_KERNEL);
if (!ns->device_path)
goto out_unlock;
@@ -963,7 +963,7 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
return -EINVAL;
}
- new_model_number = kstrndup(page, len, GFP_KERNEL);
+ new_model_number = kmemdup_nul(page, len, GFP_KERNEL);
if (!new_model_number)
return -ENOMEM;
--
2.20.1
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] nvmet: replace kstrndup() with kmemdup_nul()
2020-05-08 11:59 ` Chen Zhou
@ 2020-05-12 16:14 ` Christoph Hellwig
-1 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-05-12 16:14 UTC (permalink / raw)
To: Chen Zhou; +Cc: hch, sagi, chaitanya.kulkarni, linux-nvme, linux-kernel
On Fri, May 08, 2020 at 07:59:06PM +0800, Chen Zhou wrote:
> 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@huawei.com>
Thanks,
applied to nvme-5.8.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] nvmet: replace kstrndup() with kmemdup_nul()
@ 2020-05-12 16:14 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-05-12 16:14 UTC (permalink / raw)
To: Chen Zhou; +Cc: linux-kernel, linux-nvme, hch, chaitanya.kulkarni, sagi
On Fri, May 08, 2020 at 07:59:06PM +0800, Chen Zhou wrote:
> 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@huawei.com>
Thanks,
applied to nvme-5.8.
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-12 16:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 11:59 [PATCH -next] nvmet: replace kstrndup() with kmemdup_nul() Chen Zhou
2020-05-08 11:59 ` Chen Zhou
2020-05-12 16:14 ` Christoph Hellwig
2020-05-12 16:14 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.