Commit 193a8c7e authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Christoph Hellwig

nvme-auth: don't ignore key generation failures when initializing ctrl keys

nvme_auth_generate_key can fail, don't ignore it upon initialization.
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent f6b182fb
...@@ -972,15 +972,26 @@ static void nvme_ctrl_auth_work(struct work_struct *work) ...@@ -972,15 +972,26 @@ static void nvme_ctrl_auth_work(struct work_struct *work)
*/ */
} }
void nvme_auth_init_ctrl(struct nvme_ctrl *ctrl) int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
{ {
int ret;
INIT_LIST_HEAD(&ctrl->dhchap_auth_list); INIT_LIST_HEAD(&ctrl->dhchap_auth_list);
INIT_WORK(&ctrl->dhchap_auth_work, nvme_ctrl_auth_work); INIT_WORK(&ctrl->dhchap_auth_work, nvme_ctrl_auth_work);
mutex_init(&ctrl->dhchap_auth_mutex); mutex_init(&ctrl->dhchap_auth_mutex);
if (!ctrl->opts) if (!ctrl->opts)
return; return 0;
nvme_auth_generate_key(ctrl->opts->dhchap_secret, &ctrl->host_key); ret = nvme_auth_generate_key(ctrl->opts->dhchap_secret,
nvme_auth_generate_key(ctrl->opts->dhchap_ctrl_secret, &ctrl->ctrl_key); &ctrl->host_key);
if (ret)
return ret;
ret = nvme_auth_generate_key(ctrl->opts->dhchap_ctrl_secret,
&ctrl->ctrl_key);
if (ret) {
nvme_auth_free_key(ctrl->host_key);
ctrl->host_key = NULL;
}
return ret;
} }
EXPORT_SYMBOL_GPL(nvme_auth_init_ctrl); EXPORT_SYMBOL_GPL(nvme_auth_init_ctrl);
......
...@@ -5119,9 +5119,13 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, ...@@ -5119,9 +5119,13 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
nvme_fault_inject_init(&ctrl->fault_inject, dev_name(ctrl->device)); nvme_fault_inject_init(&ctrl->fault_inject, dev_name(ctrl->device));
nvme_mpath_init_ctrl(ctrl); nvme_mpath_init_ctrl(ctrl);
nvme_auth_init_ctrl(ctrl); ret = nvme_auth_init_ctrl(ctrl);
if (ret)
goto out_free_cdev;
return 0; return 0;
out_free_cdev:
cdev_device_del(&ctrl->cdev, ctrl->device);
out_free_name: out_free_name:
nvme_put_ctrl(ctrl); nvme_put_ctrl(ctrl);
kfree_const(ctrl->device->kobj.name); kfree_const(ctrl->device->kobj.name);
......
...@@ -1018,14 +1018,17 @@ static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl) ...@@ -1018,14 +1018,17 @@ static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
} }
#ifdef CONFIG_NVME_AUTH #ifdef CONFIG_NVME_AUTH
void nvme_auth_init_ctrl(struct nvme_ctrl *ctrl); int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl);
void nvme_auth_stop(struct nvme_ctrl *ctrl); void nvme_auth_stop(struct nvme_ctrl *ctrl);
int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid); int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid);
int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid); int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid);
void nvme_auth_reset(struct nvme_ctrl *ctrl); void nvme_auth_reset(struct nvme_ctrl *ctrl);
void nvme_auth_free(struct nvme_ctrl *ctrl); void nvme_auth_free(struct nvme_ctrl *ctrl);
#else #else
static inline void nvme_auth_init_ctrl(struct nvme_ctrl *ctrl) {}; static inline int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
{
return 0;
}
static inline void nvme_auth_stop(struct nvme_ctrl *ctrl) {}; static inline void nvme_auth_stop(struct nvme_ctrl *ctrl) {};
static inline int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid) static inline int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment