Blob Blame History Raw
From 2155a54ebfba3cdf78d48acec289b6621910eeef Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 18 Jan 2022 14:49:45 +0100
Subject: [PATCH] nvme-auth: fixup crash at boot
Patch-mainline: Submitted to linux-nvme, 2021-12-02
References: jsc#SLE-20183

For non-fabrics devices the 'opts' pointer is empty, so we need
to check before dereferencing it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/nvme/host/auth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
index 4e7959141c4f..9fd07637ab13 100644
--- a/drivers/nvme/host/auth.c
+++ b/drivers/nvme/host/auth.c
@@ -1658,6 +1658,8 @@ void nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
 	INIT_LIST_HEAD(&ctrl->dhchap_auth_list);
 	INIT_WORK(&ctrl->dhchap_auth_work, nvme_dhchap_auth_work);
 	mutex_init(&ctrl->dhchap_auth_mutex);
+	if (!ctrl->opts)
+		return;
 	nvme_auth_generate_key(ctrl->opts->dhchap_secret, &ctrl->host_key);
 	nvme_auth_generate_key(ctrl->opts->dhchap_ctrl_secret, &ctrl->ctrl_key);
 }
-- 
2.29.2