From c2cd220c90458781b5773659d8a2ca0664f44aac Mon Sep 17 00:00:00 2001 From: Sujit Reddy Thumma Date: Fri, 14 Dec 2012 19:36:58 +0530 Subject: [PATCH] cfq-iosched: Fix null pointer dereference NULL pointer dereference can happen in cfq_choose_cfqg() when there are no cfq groups to select other than the current serving group. Prevent this by adding a NULL check before dereferencing. Unable to handle kernel NULL pointer dereference at virtual address [] (cfq_dispatch_requests+0x368/0x8c0) from [] (blk_peek_request+0x220/0x25c) [] (blk_peek_request+0x220/0x25c) from [] (blk_fetch_request+0x8/0x1c) [] (blk_fetch_request+0x8/0x1c) from [] (mmc_queue_thread+0x58/0x120) [] (mmc_queue_thread+0x58/0x120) from [] (kthread+0x84/0x90) [] (kthread+0x84/0x90) from [] (kernel_thread_exit+0x0/0x8) CRs-Fixed: 416466 Change-Id: I1fab93a4334b53e1d7c5dcc8f93cff174bae0d5e Signed-off-by: Sujit Reddy Thumma --- block/cfq-iosched.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 3c38536bd52c..32629e28a634 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -2305,6 +2305,9 @@ static void cfq_choose_cfqg(struct cfq_data *cfqd) { struct cfq_group *cfqg = cfq_get_next_cfqg(cfqd); + if (!cfqg) + return; + cfqd->serving_group = cfqg; /* Restore the workload type data */