[PATCH 2/2] nvme-fabrics: use kfree_sensitive() for the old DH-HMAC-CHAP secret

Martin George martinus.gpy at gmail.com
Mon Nov 16 02:02:44 PST 2026


When a connect string overrides dhchap_secret or dhchap_ctrl_secret,
nvmf_parse_options() frees the previous raw secret with plain kfree().
The invalid-input path already uses kfree_sensitive(), so do the same
for the replaced secret.

Signed-off-by: Martin George <marting at netapp.com>
---
 drivers/nvme/host/fabrics.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index c262538523fb..5ed91557f070 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -1026,7 +1026,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 				ret = -EINVAL;
 				goto out;
 			}
-			kfree(opts->dhchap_secret);
+			kfree_sensitive(opts->dhchap_secret);
 			opts->dhchap_secret = p;
 			break;
 		case NVMF_OPT_DHCHAP_CTRL_SECRET:
@@ -1041,7 +1041,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 				ret = -EINVAL;
 				goto out;
 			}
-			kfree(opts->dhchap_ctrl_secret);
+			kfree_sensitive(opts->dhchap_ctrl_secret);
 			opts->dhchap_ctrl_secret = p;
 			break;
 		case NVMF_OPT_TLS:
-- 
2.53.0




More information about the Linux-nvme mailing list