nvme: check for a live controller in nvme_dev_open
authorChristoph Hellwig <hch@lst.de>
Wed, 18 Oct 2017 15:09:31 +0000 (17:09 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 27 Oct 2017 06:05:22 +0000 (09:05 +0300)
This is a much more sensible check than just the admin queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@rimbeg.me>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
drivers/nvme/host/core.c

index a56a1e0432e7becfdaa3d30cfd8510e4006caa9f..df525ab42fcd18c17bb55f4bbadb1dd52a12e1bf 100644 (file)
@@ -1891,7 +1891,7 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
        struct nvme_ctrl *ctrl =
                container_of(inode->i_cdev, struct nvme_ctrl, cdev);
 
-       if (!ctrl->admin_q)
+       if (ctrl->state != NVME_CTRL_LIVE)
                return -EWOULDBLOCK;
        file->private_data = ctrl;
        return 0;