mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heloise <os@iscas.ac.cn>
To: axboe@fb.com, hare@suse.com, jthumshirn@suse.de,
	keith.busch@intel.com, ming.lei@redhat.com, bianpan2016@163.com,
	dan.j.williams@intel.com, sachin.s5@samsung.com,
	baoyou.xie@linaro.org
Cc: linux-kernel@vger.kernel.org, Heloise <os@iscas.ac.cn>
Subject: [PATCH] drivers:block:mtip32xx:mtip32xx:change the order of null-pointer dereference validation
Date: Tue, 25 Apr 2017 18:30:16 -0700	[thread overview]
Message-ID: <1493170216-9035-1-git-send-email-os@iscas.ac.cn> (raw)

Signed-off-by: Heloise <os@iscas.ac.cn>

mtip_async_complete() uses the variable port 'port->dd'at the begining, then
validates null-pointer dereference of port 'unlikely(!port)'. Change the order
of validation.
---
 drivers/block/mtip32xx/mtip32xx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 1d1dc11..feed61a 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -228,10 +228,13 @@ static struct mtip_cmd *mtip_cmd_from_tag(struct driver_data *dd,
 static void mtip_async_complete(struct mtip_port *port,
 				int tag, struct mtip_cmd *cmd, int status)
 {
+	if (unlikely(!port))
+		return;
+
 	struct driver_data *dd = port->dd;
 	struct request *rq;
 
-	if (unlikely(!dd) || unlikely(!port))
+	if (unlikely(!dd))
 		return;
 
 	if (unlikely(status == PORT_IRQ_TF_ERR)) {
-- 
2.1.0

             reply	other threads:[~2017-04-26  1:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26  1:30 Heloise [this message]
2017-04-26  6:13 ` Jens Axboe
2017-04-26 17:08 ` kbuild test robot

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=1493170216-9035-1-git-send-email-os@iscas.ac.cn \
    --to=os@iscas.ac.cn \
    --cc=axboe@fb.com \
    --cc=baoyou.xie@linaro.org \
    --cc=bianpan2016@163.com \
    --cc=dan.j.williams@intel.com \
    --cc=hare@suse.com \
    --cc=jthumshirn@suse.de \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=sachin.s5@samsung.com \
    /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

all inboxes | Powered by JetHome®