lkml.org 
[lkml]   [2017]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] drviers/nvme/target: fix max dup length for kstrndup
Date
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


\
 
 \ /
  Last update: 2017-12-12 10:35    [W:0.110 / U:1.680 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site