Skip to contentSkip to conversation

block: call blk_exit_queue() before freeing q->stats

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

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block: call blk_exit_queue() before freeing q->stats

blk_stat_disable_accounting() is added in commit 68497092bde9 ("block: make queue stat accounting a reference"), and called in kyber_exit_sched().

So we have to free q->stats after elevator is unloaded from blk_exit_queue() in blk_release_queue(). Otherwise kernel panic is caused.

Fixes 68497092bde9 ("block: make queue stat accounting a reference")
---
 block/blk-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/blk-sysfs.c +2 -2
index 3e6357321225..e20eadfcf5c8 100644
@@ -791,11 +791,11 @@ static void blk_release_queue(struct kobject *kobj)
 		blk_stat_remove_callback(q, q->poll_cb);
 	blk_stat_free_callback(q->poll_cb);
 
+	blk_exit_queue(q);
+
 	blk_free_queue_stats(q->stats);
 	kfree(q->poll_stat);
 
-	blk_exit_queue(q);
-
 	blk_queue_free_zone_bitmaps(q);
 
 	if (queue_is_mq(q))
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 9 lines · Ming Lei

blk_stat_disable_accounting() is added in commit 68497092bde9 ("block: make queue stat accounting a reference"), and called in kyber_exit_sched().

So we have to free q->stats after elevator is unloaded from blk_exit_queue() in blk_release_queue(). Otherwise kernel panic is caused.

[...]

Applied, thanks!

[1/1] block: call blk_exit_queue() before freeing q->stats

      commit: 37e11c3616f6182b6bd7f95a04df035b43464f39

Best regards,

Signature · 1 line
Jens Axboe