Skip to content

Commit 353e0fb

Browse files
committed
fabrics: do not leak nvme_ctrl_t object on connect
valgrinds reports that the nvme_ctrl_t is leaked in the connect command. Let's introduced a new cleanup helper for this. Signed-off-by: Daniel Wagner <dwagner@suse.de>
1 parent 0598cd6 commit 353e0fb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

fabrics.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ int nvmf_connect(const char *desc, int argc, char **argv)
899899
unsigned int verbose = 0;
900900
_cleanup_nvme_root_ nvme_root_t r = NULL;
901901
nvme_host_t h;
902-
nvme_ctrl_t c;
902+
_cleanup_nvme_ctrl_ nvme_ctrl_t c = NULL;
903903
int ret;
904904
nvme_print_flags_t flags;
905905
struct nvme_fabrics_config cfg = { 0 };

util/cleanup.h

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ static inline void cleanup_nvme_root(nvme_root_t *r)
4242
}
4343
#define _cleanup_nvme_root_ __cleanup__(cleanup_nvme_root)
4444

45+
static inline DEFINE_CLEANUP_FUNC(cleanup_nvme_ctrl, nvme_ctrl_t, nvme_free_ctrl)
46+
#define _cleanup_nvme_ctrl_ __cleanup__(cleanup_nvme_ctrl)
47+
4548
static inline void free_uri(struct nvme_fabrics_uri **uri)
4649
{
4750
if (*uri)

0 commit comments

Comments
 (0)