Skip to contentSkip to conversation

blk-mq: check q->poll_stat in queue_poll_stat_show

PATCH Applied Ming Lei 2 participants 2 messages Dec 2, 2021 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 blk-mq: check q->poll_stat in queue_poll_stat_show

Without checking q->poll_stat in queue_poll_stat_show(), kernel panic may be caused if q->poll_stat isn't allocated.

Fixes 48b5c1fbcd8c ("block: only allocate poll_stats if there's a user of them")
---
 block/blk-mq-debugfs.c | 3 +++
 1 file changed, 3 insertions(+)
block/blk-mq-debugfs.c +3 -0
index 7f27dca3a45e..3a790eb4995c 100644
@@ -30,6 +30,9 @@ static int queue_poll_stat_show(void *data, struct seq_file *m)
 	struct request_queue *q = data;
 	int bucket;
 
+	if (!q->poll_stat)
+		return 0;
+
 	for (bucket = 0; bucket < (BLK_MQ_POLL_STATS_BKTS / 2); bucket++) {
 		seq_printf(m, "read  (%d Bytes): ", 1 << (9 + bucket));
 		print_stat(m, &q->poll_stat[2 * bucket]);
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 4 lines · Ming Lei

Without checking q->poll_stat in queue_poll_stat_show(), kernel panic may be caused if q->poll_stat isn't allocated.

Applied, thanks!

[1/1] blk-mq: check q->poll_stat in queue_poll_stat_show

      commit: 18d78171c061889a9a43152f60d6a27a10fc7656

Best regards,

Signature · 1 line
Jens Axboe