diff options
author | Ma Shimiao <mashimiao.fnst@cn.fujitsu.com> | 2017-12-12 12:39:10 +0300 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2018-01-17 17:16:16 +0300 |
commit | 4b259fc4a8a12dcd0ffd670877a7a1ca2ab0f3e3 (patch) | |
tree | 948cf6d3629f6ce40f142532faaca9121c2d65f3 /drivers/md | |
parent | d5ffebdd797a7c1c89576267640f671db2a668fc (diff) | |
download | linux-4b259fc4a8a12dcd0ffd670877a7a1ca2ab0f3e3.tar.xz |
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: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-log-writes.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 189badbeddaf..3362d866793b 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c @@ -594,7 +594,7 @@ static int log_mark(struct log_writes_c *lc, char *data) return -ENOMEM; } - block->data = kstrndup(data, maxsize, GFP_KERNEL); + block->data = kstrndup(data, maxsize - 1, GFP_KERNEL); if (!block->data) { DMERR("Error copying mark data"); kfree(block); |