blk-cgroup: fix disk reference leak in blkcg_maybe_throttle_current()
Subsystems (3)
PATCH 1/1 blk-cgroup: fix disk reference leak in blkcg_maybe_throttle_current()
From: Jackie Liu <[email protected]>
Add the missing put_disk() on the error path in blkcg_maybe_throttle_current(). When blkcg lookup, blkg lookup, or blkg_tryget() fails, the function jumps to the out label which only calls rcu_read_unlock() but does not release the disk reference acquired by blkcg_schedule_throttle() via get_device(). Since current->throttle_disk is already set to NULL before the lookup, blkcg_exit() cannot release this reference either, causing the disk to never be freed.
Restore the reference release that was present as blk_put_queue() in the original code but was inadvertently dropped during the conversion from request_queue to gendisk.
--- block/blk-cgroup.c | 1 + 1 file changed, 1 insertion(+)
block/blk-cgroup.c +1 -0
@@ -2022,6 +2022,7 @@ void blkcg_maybe_throttle_current(void)return ; out:rcu_read_unlock (); +put_disk (disk); }/**
Signature · 1 line
2.51.1
Quoted 10 lines · Jackie Liu
From: Jackie Liu <[email protected]>
Add the missing
put_disk()on the error path inblkcg_maybe_throttle_current(). When blkcg lookup, blkg lookup, orblkg_tryget()fails, the function jumps to the out label which only callsrcu_read_unlock()but does not release the disk reference acquired byblkcg_schedule_throttle()viaget_device(). Sincecurrent->throttle_diskis already set to NULL before the lookup,blkcg_exit()cannot release this reference either, causing the disk to never be freed.
Quoted 3 lines
Restore the reference release that was present as
blk_put_queue()in the original code but was inadvertently dropped during the conversion fromrequest_queueto gendisk.
Looks good:
Quoted 8 lines · Jackie Liu
Add the missing
put_disk()on the error path inblkcg_maybe_throttle_current(). When blkcg lookup, blkg lookup, orblkg_tryget()fails, the function jumps to the out label which only callsrcu_read_unlock()but does not release the disk reference acquired byblkcg_schedule_throttle()viaget_device(). Sincecurrent->throttle_diskis already set to NULL before the lookup,blkcg_exit()cannot release this reference either, causing the disk to never be freed.
Quoted 6 lines
Restore the reference release that was present as
blk_put_queue()in the original code but was inadvertently dropped during the conversion fromrequest_queueto gendisk.Fixes f05837ed73d0 ("blk-cgroup: store a gendisk to throttle in struct task_struct")Signed-off-by Jackie Liu <[email protected]>
Thanks.
Signature · 1 line
tejun
Quoted 9 lines · Jackie Liu
Add the missing
put_disk()on the error path inblkcg_maybe_throttle_current(). When blkcg lookup, blkg lookup, orblkg_tryget()fails, the function jumps to the out label which only callsrcu_read_unlock()but does not release the disk reference acquired byblkcg_schedule_throttle()viaget_device(). Sincecurrent->throttle_diskis already set to NULL before the lookup,blkcg_exit()cannot release this reference either, causing the disk to never be freed.[...]
Applied, thanks!
[1/1] blk-cgroup: fix disk reference leak in blkcg_maybe_throttle_current()
commit: 23308af722fefed00af5f238024c11710938fba3
Best regards,
Signature · 1 line
Jens Axboe