2007-10-20 13:06:54

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH] cfq_get_queue: fix possible NULL pointer access

cfq_get_queue()->cfq_find_alloc_queue() can fail, check the returned value.

Signed-off-by: Oleg Nesterov <[email protected]>

--- K/block/cfq-iosched.c~3_get 2007-10-20 15:48:35.000000000 +0400
+++ K/block/cfq-iosched.c 2007-10-20 17:05:30.000000000 +0400
@@ -1443,8 +1443,11 @@ cfq_get_queue(struct cfq_data *cfqd, int
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


2007-10-21 19:16:31

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] cfq_get_queue: fix possible NULL pointer access

On Sat, Oct 20 2007, Oleg Nesterov wrote:
> cfq_get_queue()->cfq_find_alloc_queue() can fail, check the returned value.

Thanks, applied! No normal IO paths use it without __GFP_WAIT, so it's
not a critical fix. But that could change in the future and then cause
allocation failure, so I'll add the patch.

--
Jens Axboe