* [PATCH] drviers/nvme/target: fix max dup length for kstrndup
@ 2017-12-12 9:36 Ma Shimiao
2018-01-14 10:34 ` Sagi Grimberg
0 siblings, 1 reply; 2+ messages in thread
From: Ma Shimiao @ 2017-12-12 9:36 UTC (permalink / raw)
To: hch, sagi; +Cc: linux-kernel, linux-nvme, Ma Shimiao
If source string longer than max, kstrndup will alloc max+1 space.
So, we should make sure the result will not over limit.
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
---
drivers/nvme/target/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index b54748ad5f48..0ca259ee4dea 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -975,7 +975,7 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
return NULL;
}
subsys->type = type;
- subsys->subsysnqn = kstrndup(subsysnqn, NVMF_NQN_SIZE,
+ subsys->subsysnqn = kstrndup(subsysnqn, NVMF_NQN_SIZE - 1,
GFP_KERNEL);
if (!subsys->subsysnqn) {
kfree(subsys);
--
2.13.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drviers/nvme/target: fix max dup length for kstrndup
2017-12-12 9:36 [PATCH] drviers/nvme/target: fix max dup length for kstrndup Ma Shimiao
@ 2018-01-14 10:34 ` Sagi Grimberg
0 siblings, 0 replies; 2+ messages in thread
From: Sagi Grimberg @ 2018-01-14 10:34 UTC (permalink / raw)
To: Ma Shimiao, hch; +Cc: linux-kernel, linux-nvme
Looks good,
Reviewed-by: Sagi Grimberg <sagi@grmberg.me>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-14 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12 9:36 [PATCH] drviers/nvme/target: fix max dup length for kstrndup Ma Shimiao
2018-01-14 10:34 ` Sagi Grimberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).