Skip to content

Commit 5159e08

Browse files
martin-gpyigaw
authored andcommitted
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 <[email protected]>
1 parent 4d3d6ac commit 5159e08

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

libnvme/src/nvme/fabrics.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,8 @@ int nvmf_discovery_config_file(struct nvme_global_ctx *ctx,
25882588
nvme_free_ctrl(c);
25892589
} while (!err);
25902590

2591+
fctx->parser_cleanup(fctx, fctx->user_data);
2592+
25912593
if (err != -EOF)
25922594
return err;
25932595

0 commit comments

Comments
 (0)