Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Oleg Nesterov and committed by
Jens Axboe
0a0836a0 abbeb88d

+4 -1
+4 -1
block/cfq-iosched.c
··· 1443 1443 cfqq = *async_cfqq; 1444 1444 } 1445 1445 1446 - if (!cfqq) 1446 + if (!cfqq) { 1447 1447 cfqq = cfq_find_alloc_queue(cfqd, is_sync, tsk, gfp_mask); 1448 + if (!cfqq) 1449 + return NULL; 1450 + } 1448 1451 1449 1452 /* 1450 1453 * pin the queue now that it's allocated, scheduler exit will prune it