nvme-fabrics: verify that a controller returns the correct NQN
authorChristoph Hellwig <[email protected]>
Mon, 26 Jun 2017 10:39:04 +0000 (12:39 +0200)
committerJens Axboe <[email protected]>
Wed, 28 Jun 2017 14:14:13 +0000 (08:14 -0600)
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Sagi Grimberg <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Sagi Grimberg <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
drivers/nvme/host/fabrics.c

index 7996e95383d461397e285b67baafd169a4ae9eb4..2e582a2409437bca7d603598290d023bd988c577 100644 (file)
@@ -872,6 +872,15 @@ nvmf_create_ctrl(struct device *dev, const char *buf, size_t count)
                goto out_unlock;
        }
 
+       if (strcmp(ctrl->subnqn, opts->subsysnqn)) {
+               dev_warn(ctrl->device,
+                       "controller returned incorrect NQN: \"%s\".\n",
+                       ctrl->subnqn);
+               mutex_unlock(&nvmf_transports_mutex);
+               ctrl->ops->delete_ctrl(ctrl);
+               return ERR_PTR(-EINVAL);
+       }
+
        mutex_unlock(&nvmf_transports_mutex);
        return ctrl;