Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1631091
| From | Heloise <os@iscas.ac.cn> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] drivers:block:mtip32xx:mtip32xx:change the order of null-pointer dereference validation |
| Date | 2017-04-26 03:40 +0200 |
| Message-ID | <tAk5X-3X0-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] drivers:block:mtip32xx:mtip32xx:change the order of null-pointer dereference validation Heloise <os@iscas.ac.cn> - 2017-04-26 03:40 +0200
csiph-web