Message ID | 20241004123922.35834-1-surajsonawane0215@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: Fix elevator_get_default() to check for null q->tag_set | expand |
> static struct elevator_type *elevator_get_default(struct request_queue *q) > { > - if (q->tag_set && q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT) > - return NULL; > + if (q->tag_set) { q->tag_set can't be NULL for a blk-mq queue. So you can just remove the q->tag_set check here and also in elv_support_iosched.
diff --git a/block/elevator.c b/block/elevator.c index 4122026b1..9ca32a6bd 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -562,12 +562,14 @@ static inline bool elv_support_iosched(struct request_queue *q) */ static struct elevator_type *elevator_get_default(struct request_queue *q) { - if (q->tag_set && q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT) - return NULL; + if (q->tag_set) { + if (q->tag_set->flags & BLK_MQ_F_NO_SCHED_BY_DEFAULT) + return NULL; - if (q->nr_hw_queues != 1 && - !blk_mq_is_shared_tags(q->tag_set->flags)) - return NULL; + if (q->nr_hw_queues != 1 && + !blk_mq_is_shared_tags(q->tag_set->flags)) + return NULL; + } return elevator_find_get(q, "mq-deadline"); }
Fix null pointer error by checking if q->tag_set is null. Address "block/elevator.c:569 elevator_get_default() error: we previously assumed 'q->tag_set' could be null (see line 565)" This change prevents errors by making sure q->tag_set is valid before accessing its flags. Signed-off-by: SurajSonawane2415 <surajsonawane0215@gmail.com> --- block/elevator.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)