]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
blk-throttle: fix potential NULL pointer dereference in throtl_select_dispatch
authorLiu Bo <bo.liu@linux.alibaba.com>
Tue, 29 May 2018 08:29:12 +0000 (16:29 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 30 May 2018 16:54:33 +0000 (10:54 -0600)
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>
block/blk-throttle.c

index f63d88c92c3aeba8b22195dca1512fbaeb6c2b69..35bed770664d13c807ea770155f1d1f02ffedd8d 100644 (file)
@@ -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);