From cd384b4e2711daf53bacfe1511209d12e90638b1 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 24 Jul 2025 20:37:17 +0200 Subject: [PATCH 1/2] json: do not leak port_obj for PCI devices When the transport is pcie the port_obj is leaked. Signed-off-by: Daniel Wagner --- src/nvme/json.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nvme/json.c b/src/nvme/json.c index a2fe8173e..992a54373 100644 --- a/src/nvme/json.c +++ b/src/nvme/json.c @@ -287,8 +287,10 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c) const char *transport, *value; transport = nvme_ctrl_get_transport(c); - if (!strcmp(transport, "pcie")) + if (!strcmp(transport, "pcie")) { + json_object_put(port_obj); return; + } json_object_object_add(port_obj, "transport", json_object_new_string(transport)); From d72495206e3a45bf7e3e443e70f864eeebfffa0d Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 24 Jul 2025 20:20:04 +0200 Subject: [PATCH 2/2] tree: always set the host key The current logic will not set the host secret to the controller when the sysfs value and the value from the host object are identically. Setting the secret from the host object to the controller is not what this function is supposed to do. It should read the value from the sysfs. Signed-off-by: Daniel Wagner --- src/nvme/tree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/nvme/tree.c b/src/nvme/tree.c index 7241163bf..9aaaa1b50 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -1984,9 +1984,7 @@ static void nvme_read_sysfs_dhchap(nvme_root_t r, nvme_ctrl_t c) char *host_key, *ctrl_key; host_key = nvme_get_ctrl_attr(c, "dhchap_secret"); - if (host_key && c->s && c->s->h && c->s->h->dhchap_key && - (!strcmp(c->s->h->dhchap_key, host_key) || - !strcmp("none", host_key))) { + if (host_key && !strcmp(host_key, "none")) { free(host_key); host_key = NULL; }