Skip to contentSkip to conversation

blk-throttle: fix potential NULL pointer dereference in throtl_select_dispatch

PATCH Joseph Qi 1 participant 1 message Aug 10, 2017

Subsystems (2)
lore
Share & tools
lore

Joseph Qi

author
#0 lore raw

From: Joseph Qi <[email protected]>

Since throtl_rb_first may return NULL, so it should check tg first and then use it.

---
 block/blk-throttle.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-throttle.c +2 -1
index a7285bf..c1d2c5b 100644
@@ -1201,7 +1201,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;
@@ -1213,6 +1213,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);
 
Signature · 1 line
1.9.4