[PATCH] blk-throttle: fix throtl_data leak during disk release
From: Yu Kuai
Date: Mon Sep 15 2025 - 21:19:38 EST
From: Yu Kuai <yukuai3@xxxxxxxxxx>
Tightening the throttle activation check in blk_throtl_activated() to
require both q->td presence and policy bit set introduced a memory leak
during disk release:
blkg_destroy_all() clears the policy bit first during queue deactivation,
causing subsequent blk_throtl_exit() to skip throtl_data cleanup when
blk_throtl_activated() fails policy check.
Fix by reordering operations in disk_release() to call blk_throtl_exit()
while throttle policy is still active. We avoid modifying blk_throtl_exit()
activation check because it's intuitive that blk-throtl start from
blk_throtl_init() and end in blk_throtl_exit().
Fixes: bd9fd5be6bc0 ("blk-throttle: fix access race during throttle policy activation")
Reported-by: Yi Zhang <yi.zhang@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/CAHj4cs-p-ZwBEKigBj7T6hQCOo-H68-kVwCrV6ZvRovrr9Z+HA@xxxxxxxxxxxxxx/
Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
block/blk-cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 7246fc256315..64a56c8697f9 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1539,8 +1539,8 @@ int blkcg_init_disk(struct gendisk *disk)
void blkcg_exit_disk(struct gendisk *disk)
{
- blkg_destroy_all(disk);
blk_throtl_exit(disk);
+ blkg_destroy_all(disk);
}
static void blkcg_exit(struct task_struct *tsk)
--
2.39.2