From: Leonardo Bras <leonardo@linux.ibm.com>
To: linux-block@vger.kernel.org
Cc: Leonardo Bras <leonardo@linux.ibm.com>,
Jens Axboe <axboe@kernel.dk>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/1] block/cfq : Include check to avoid NULL Pointer Dereferencing
Date: Thu, 13 Jun 2019 20:31:59 -0300 [thread overview]
Message-ID: <20190613233159.26687-2-leonardo@linux.ibm.com> (raw)
In-Reply-To: <20190613233159.26687-1-leonardo@linux.ibm.com>
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 --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
prev parent reply other threads:[~2019-06-13 23:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 23:31 [RFC PATCH 0/1] block/cfq : Include check to avoid NULL Pointer Leonardo Bras
2019-06-13 23:31 ` Leonardo Bras [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190613233159.26687-2-leonardo@linux.ibm.com \
--to=leonardo@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).