summaryrefslogtreecommitdiffstats
path: root/block/blk-throttle.c
diff options
context:
space:
mode:
authorLiu Bo <bo.liu@linux.alibaba.com>2018-05-29 10:29:12 +0200
committerJens Axboe <axboe@kernel.dk>2018-05-30 18:54:33 +0200
commit2ab74cd29622c48e9852d85618081c061b6ac6d9 (patch)
tree16058bed4d103d7202f997b2d4e511a185e0c8e5 /block/blk-throttle.c
parentblock: kyber: make kyber more friendly with merging (diff)
downloadlinux-2ab74cd29622c48e9852d85618081c061b6ac6d9.tar.xz
linux-2ab74cd29622c48e9852d85618081c061b6ac6d9.zip
blk-throttle: fix potential NULL pointer dereference in throtl_select_dispatch
tg in throtl_select_dispatch is used first and then do check. Since tg may be NULL, it has potential NULL pointer dereference risk. So fix it. Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com> Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r--block/blk-throttle.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index f63d88c92c3a..35bed770664d 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -1207,7 +1207,7 @@ static int throtl_select_dispatch(struct throtl_service_queue *parent_sq)
while (1) {
struct throtl_grp *tg = throtl_rb_first(parent_sq);
- struct throtl_service_queue *sq = &tg->service_queue;
+ struct throtl_service_queue *sq;
if (!tg)
break;
@@ -1219,6 +1219,7 @@ static int throtl_select_dispatch(struct throtl_service_queue *parent_sq)
nr_disp += throtl_dispatch_tg(tg);
+ sq = &tg->service_queue;
if (sq->nr_queued[0] || sq->nr_queued[1])
tg_update_disptime(tg);