linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers:block:mtip32xx:mtip32xx:change the order of null-pointer dereference validation
@ 2017-04-26  1:30 Heloise
  2017-04-26  6:13 ` Jens Axboe
  2017-04-26 17:08 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Heloise @ 2017-04-26  1:30 UTC (permalink / raw)
  To: axboe, hare, jthumshirn, keith.busch, ming.lei, bianpan2016,
	dan.j.williams, sachin.s5, baoyou.xie
  Cc: linux-kernel, Heloise

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-26 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  1:30 [PATCH] drivers:block:mtip32xx:mtip32xx:change the order of null-pointer dereference validation Heloise
2017-04-26  6:13 ` Jens Axboe
2017-04-26 17:08 ` kbuild test robot

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).