Commit 0ce5c0c7 authored by Ming Lei's avatar Ming Lei Committed by Kleber Sacilotto de Souza

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

BugLink: https://bugs.launchpad.net/bugs/1858489

commit d2c9be89 upstream.

8962842c ("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: 8962842c ("blk-mq: avoid sysfs buffer overflow with too many CPU cores")
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Cc: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 02d77c6a
......@@ -248,7 +248,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;
}
......
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