Skip to content

Commit

Permalink
cfq_get_queue: fix possible NULL pointer access
Browse files Browse the repository at this point in the history
cfq_get_queue()->cfq_find_alloc_queue() can fail, check the returned value.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

Note that this isn't a bug at the moment, since the regular IO path
does not call this path without __GFP_WAIT set. However, it could be a
future bug, so I've applied it.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Oleg Nesterov authored and Jens Axboe committed Oct 29, 2007
1 parent abbeb88 commit 0a0836a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,8 +1443,11 @@ cfq_get_queue(struct cfq_data *cfqd, int is_sync, struct task_struct *tsk,
cfqq = *async_cfqq;
}

if (!cfqq)
if (!cfqq) {
cfqq = cfq_find_alloc_queue(cfqd, is_sync, tsk, gfp_mask);
if (!cfqq)
return NULL;
}

/*
* pin the queue now that it's allocated, scheduler exit will prune it
Expand Down

0 comments on commit 0a0836a

Please sign in to comment.