From 53b57b531a5e82aabc6750c4137bba7b6cc9649b Mon Sep 17 00:00:00 2001 From: Martin George Date: Sat, 3 Jan 2026 22:24:55 +0530 Subject: [PATCH 1/2] fabrics: fix uninitialized value in _nvmf_discovery() Valgrind complained about a conditional jump or move depending on an uninitialized value created by a stack allocation at _nvmf_discovery(): ==16682== Conditional jump or move depends on uninitialised value(s) ==16682== at 0x4879DA5: _nvmf_discovery (fabrics.c:2198) ==16682== by 0x487B341: _discovery_config_json (fabrics.c:2424) ==16682== by 0x487B549: nvmf_discovery_config_json (fabrics.c:2461) ==16682== by 0x409A70: fabrics_discovery (fabrics.c:569) ==16682== by 0x446358: handle_plugin (plugin.c:190) ==16682== by 0x407760: main (nvme.c:11029) ==16682== Uninitialised value was created by a stack allocation ==16682== at 0x4879AF2: _nvmf_discovery (fabrics.c:2102) Fix the same. Signed-off-by: Martin George --- libnvme/src/nvme/fabrics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 8ad16391f5..167be5d17c 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -2134,7 +2134,7 @@ static int _nvmf_discovery(struct nvme_global_ctx *ctx, nvme_ctrl_t cl; bool discover = false; bool disconnect; - nvme_ctrl_t child; + nvme_ctrl_t child = { 0 }; int tmo = fctx->cfg->keep_alive_tmo; struct fabric_args trcfg = { From 49581352ba20a817ed7df11e54a6b2879a3fb9c9 Mon Sep 17 00:00:00 2001 From: Martin George Date: Sat, 3 Jan 2026 22:30:28 +0530 Subject: [PATCH 2/2] fabrics: fix mem leak at nvmf_discovery_config_file() Valgrind revealed a mem leak caused due to not invoking parser_cleanup for the corresponding parser_init at nvmf_discovery_config_file(): ==16682== 256 bytes in 1 blocks are definitely lost in loss record 1 of 2 ==16682== at 0x4848C31: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==16682== by 0x40881A: cb_parser_init (fabrics.c:254) ==16682== by 0x487B8A2: nvmf_discovery_config_file (fabrics.c:2554) ==16682== by 0x4099F6: fabrics_discovery (fabrics.c:574) ==16682== by 0x446358: handle_plugin (plugin.c:190) ==16682== by 0x407760: main (nvme.c:11029) ==16682== ==16682== 472 bytes in 1 blocks are still reachable in loss record 2 of 2 ==16682== at 0x4841984: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==16682== by 0x494C7CA: __fopen_internal (in /lib64/libc.so.6) ==16682== by 0x408802: cb_parser_init (fabrics.c:248) ==16682== by 0x487B8A2: nvmf_discovery_config_file (fabrics.c:2554) ==16682== by 0x4099F6: fabrics_discovery (fabrics.c:574) ==16682== by 0x446358: handle_plugin (plugin.c:190) ==16682== by 0x407760: main (nvme.c:11029) Fix the same. Signed-off-by: Martin George --- libnvme/src/nvme/fabrics.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 167be5d17c..89cdbed9bc 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -2588,6 +2588,8 @@ int nvmf_discovery_config_file(struct nvme_global_ctx *ctx, nvme_free_ctrl(c); } while (!err); + fctx->parser_cleanup(fctx, fctx->user_data); + if (err != -EOF) return err;