block, bfq: move forward the getting of an extra ref in bfq_bfqq_move
authorPaolo Valente <paolo.valente@linaro.org>
Sat, 21 Mar 2020 09:45:18 +0000 (10:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 14:11:55 +0000 (16:11 +0200)
commit684e1511a801d3e3053da40d3ee85c8d3edd7109
tree213cd7539183feb55c16c5bfb85c78104359e90b
parent6bca328e67e7b0af8ab78617664cbe6f6838407d
block, bfq: move forward the getting of an extra ref in bfq_bfqq_move

[ Upstream commit fd1bb3ae54a9a2e0c42709de861c69aa146b8955 ]

Commit ecedd3d7e199 ("block, bfq: get extra ref to prevent a queue
from being freed during a group move") gets an extra reference to a
bfq_queue before possibly deactivating it (temporarily), in
bfq_bfqq_move(). This prevents the bfq_queue from disappearing before
being reactivated in its new group.

Yet, the bfq_queue may also be expired (i.e., its service may be
stopped) before the bfq_queue is deactivated. And also an expiration
may lead to a premature freeing. This commit fixes this issue by
simply moving forward the getting of the extra reference already
introduced by commit ecedd3d7e199 ("block, bfq: get extra ref to
prevent a queue from being freed during a group move").

Reported-by: cki-project@redhat.com
Tested-by: cki-project@redhat.com
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/bfq-cgroup.c