Skip to contentSkip to conversation

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

PATCH Applied Ming Lei 2 participants 2 messages Nov 4, 2019 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 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 charactor 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")
---
 block/blk-mq-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq-sysfs.c +1 -1
index 4caa56d1bc85..062229395a50 100644
@@ -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;
 }
 
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Ming Lei

8962842ca5ab ("blk-mq: avoid sysfs buffer overflow with too many CPU cores") avoids sysfs buffer overflow, and reserves one charactor 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")

Applied, thanks.

Signature · 1 line
Jens Axboe