Skip to content

Commit

Permalink
blk-mq: make sure that line break can be printed
Browse files Browse the repository at this point in the history
8962842 ("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: 8962842 ("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>
  • Loading branch information
Ming Lei authored and Jens Axboe committed Nov 4, 2019
1 parent 62c441c commit d2c9be8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/blk-mq-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d2c9be8

Please sign in to comment.