فهرست منبع

bfq-iosched: fix NULL ioc check in bfq_get_rq_private

icq_to_bic is a container_of operation, so we need to check for NULL
before it.  Also move the check outside the spinlock while we're at
it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Christoph Hellwig 8 سال پیش
والد
کامیت
9f21073826
1فایلهای تغییر یافته به همراه5 افزوده شده و 10 حذف شده
  1. 5 10
      block/bfq-iosched.c

+ 5 - 10
block/bfq-iosched.c

@@ -4398,16 +4398,17 @@ static int bfq_get_rq_private(struct request_queue *q, struct request *rq,
 			      struct bio *bio)
 			      struct bio *bio)
 {
 {
 	struct bfq_data *bfqd = q->elevator->elevator_data;
 	struct bfq_data *bfqd = q->elevator->elevator_data;
-	struct bfq_io_cq *bic = icq_to_bic(rq->elv.icq);
+	struct bfq_io_cq *bic;
 	const int is_sync = rq_is_sync(rq);
 	const int is_sync = rq_is_sync(rq);
 	struct bfq_queue *bfqq;
 	struct bfq_queue *bfqq;
 	bool new_queue = false;
 	bool new_queue = false;
 	bool split = false;
 	bool split = false;
 
 
-	spin_lock_irq(&bfqd->lock);
+	if (!rq->elv.icq)
+		return 1;
+	bic = icq_to_bic(rq->elv.icq);
 
 
-	if (!bic)
-		goto queue_fail;
+	spin_lock_irq(&bfqd->lock);
 
 
 	bfq_check_ioprio_change(bic, bio);
 	bfq_check_ioprio_change(bic, bio);
 
 
@@ -4465,13 +4466,7 @@ static int bfq_get_rq_private(struct request_queue *q, struct request *rq,
 		bfq_handle_burst(bfqd, bfqq);
 		bfq_handle_burst(bfqd, bfqq);
 
 
 	spin_unlock_irq(&bfqd->lock);
 	spin_unlock_irq(&bfqd->lock);
-
 	return 0;
 	return 0;
-
-queue_fail:
-	spin_unlock_irq(&bfqd->lock);
-
-	return 1;
 }
 }
 
 
 static void bfq_idle_slice_timer_body(struct bfq_queue *bfqq)
 static void bfq_idle_slice_timer_body(struct bfq_queue *bfqq)