NTB: Fix oops in debugfs when transport is half-up
authorDave Jiang <dave.jiang@intel.com>
Mon, 13 Jul 2015 12:07:11 +0000 (08:07 -0400)
committerJon Mason <jdmason@kudzu.us>
Sun, 9 Aug 2015 20:32:22 +0000 (16:32 -0400)
When the remote side is not up, we do not have all the context for the
transport, and that causes NULL ptr access. Have the debugfs reads check
to see if transport is up before we make access.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
drivers/ntb/ntb_transport.c

index 25e973ff64cfba63a323027a9acaa1347e2c9527..a049f96fab8d44c335e94c9f69d8b48dfbc1e281 100644 (file)
@@ -439,13 +439,17 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
        char *buf;
        ssize_t ret, out_offset, out_count;
 
+       qp = filp->private_data;
+
+       if (!qp || !qp->link_is_up)
+               return 0;
+
        out_count = 1000;
 
        buf = kmalloc(out_count, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
-       qp = filp->private_data;
        out_offset = 0;
        out_offset += snprintf(buf + out_offset, out_count - out_offset,
                               "NTB QP stats\n");