summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2019-11-04 11:26:53 +0300
committerJens Axboe <axboe@kernel.dk>2019-11-04 17:14:10 +0300
commitd2c9be89f8ebe7ebcc97676ac40f8dec1cf9b43a (patch)
treed6ebe8b26cbd810c7c41da6a4ed38569f3398c14 /block
parent62c441c6ae054a0f9ff2944908ed09603b035fd3 (diff)
downloadlinux-d2c9be89f8ebe7ebcc97676ac40f8dec1cf9b43a.tar.xz
blk-mq: make sure that line break can be printed
8962842ca5ab ("blk-mq: avoid sysfs buffer overflow with too many CPU cores") avoids sysfs buffer overflow, and reserves one character for line break. However, the last snprintf() doesn't get correct 'size' parameter passed in, so fixed it. Fixes: 8962842ca5ab ("blk-mq: avoid sysfs buffer overflow with too many CPU cores") Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-mq-sysfs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index 4caa56d1bc85..062229395a50 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -175,7 +175,7 @@ static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)
pos += ret;
}
- ret = snprintf(pos + page, size - pos, "\n");
+ ret = snprintf(pos + page, size + 1 - pos, "\n");
return pos + ret;
}