[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20190613233159.26687-2-leonardo@linux.ibm.com>
Date: Thu, 13 Jun 2019 20:31:59 -0300
From: Leonardo Bras <leonardo@...ux.ibm.com>
To: linux-block@...r.kernel.org
Cc: Leonardo Bras <leonardo@...ux.ibm.com>,
Jens Axboe <axboe@...nel.dk>, linux-kernel@...r.kernel.org
Subject: [RFC PATCH 1/1] block/cfq : Include check to avoid NULL Pointer Dereferencing
Checks if cfqg is a valid pointer before dereferencing.
There is a explicit chance for cfqg = cfq_get_next_cfqg() to return NULL,
so 'cfqg->saved_wl_slice' would be a Null dereferencing.
Signed-off-by: Leonardo Bras <leonardo@...ux.ibm.com>
---
block/cfq-iosched.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 2eb87444b157..2c5dd5a295ee 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3210,9 +3210,13 @@ static struct cfq_group *cfq_get_next_cfqg(struct cfq_data *cfqd)
static void cfq_choose_cfqg(struct cfq_data *cfqd)
{
- struct cfq_group *cfqg = cfq_get_next_cfqg(cfqd);
+ struct cfq_group *cfqg;
u64 now = ktime_get_ns();
+ cfqg = cfq_get_next_cfqg(cfqd);
+ if (unlikely(!cfqg))
+ return;
+
cfqd->serving_group = cfqg;
/* Restore the workload type data */
--
2.20.1
Powered by blists - more mailing lists