diff mbox series

[RFC,1/1] block/cfq : Include check to avoid NULL Pointer Dereferencing

Message ID 20190613233159.26687-2-leonardo@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series block/cfq : Include check to avoid NULL Pointer | expand

Commit Message

Leonardo Bras June 13, 2019, 11:31 p.m. UTC
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@linux.ibm.com>
---
 block/cfq-iosched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

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