Commit 4b259fc4 authored by Ma Shimiao's avatar Ma Shimiao Committed by Mike Snitzer

dm log writes: fix max length used for kstrndup

If source string is longer than max, kstrndup will allocate max+1
space.  So make sure the result will not exceed max.
Signed-off-by: default avatarMa Shimiao <mashimiao.fnst@cn.fujitsu.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent d5ffebdd
...@@ -594,7 +594,7 @@ static int log_mark(struct log_writes_c *lc, char *data) ...@@ -594,7 +594,7 @@ static int log_mark(struct log_writes_c *lc, char *data)
return -ENOMEM; return -ENOMEM;
} }
block->data = kstrndup(data, maxsize, GFP_KERNEL); block->data = kstrndup(data, maxsize - 1, GFP_KERNEL);
if (!block->data) { if (!block->data) {
DMERR("Error copying mark data"); DMERR("Error copying mark data");
kfree(block); kfree(block);
......
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