blk-mq: make sure that line break can be printed

commit d2c9be89f8 upstream.

8962842ca5 ("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: 8962842ca5 ("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>
Cc: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ming Lei 2019-11-04 16:26:53 +08:00 committed by Greg Kroah-Hartman
parent d7248f5a0b
commit d88fb4f0b0

View file

@ -168,7 +168,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;
}