Skip to contentSkip to conversation

blk-throttle: fix potential NULL pointer dereference in throtl_select_dispatch

PATCH RESEND Applied Liu Bo 2 participants 2 messages May 29, 2018 – May 30, 2018

Subsystems (2)
lore
Share & tools
lore

Liu Bo

author
#0 lore raw

PATCH RESEND 1/1 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.

---
 block/blk-throttle.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-throttle.c +2 -1
index dffe982..a168e82 100644
@@ -1294,7 +1294,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;
@@ -1306,6 +1306,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.8.3.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Liu Bo

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.

Applied, thanks.

Signature · 1 line
Jens Axboe