[PATCH] plugin/lm: avoid closing migration-send input twice

Kundan Kumar kundan.kumar at samsung.com
Wed Jul 29 02:12:41 PDT 2026


lm_migration_send() declares the input stream with __cleanup_file, which
closes the stream automatically when the function returns. The function
also calls fclose() explicitly after fread() without clearing the
pointer.

The cleanup handler consequently closes the same stream again, causing
glibc to abort with:

    free(): double free detected in tcache 2

Remove the explicit fclose() and let __cleanup_file close the stream.

Fixes: 6d2a869dd054 ("plugin/lm: Introduce Live Migration plugin")

Signed-off-by: Kundan Kumar <kundan.kumar at samsung.com>
---
 plugins/lm/lm-nvme.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/plugins/lm/lm-nvme.c b/plugins/lm/lm-nvme.c
index ed6fb7505..7b70a47cb 100644
--- a/plugins/lm/lm-nvme.c
+++ b/plugins/lm/lm-nvme.c
@@ -364,8 +364,6 @@ static int lm_migration_send(int argc, char **argv, struct command *acmd, struct
 
 		size_t n_data = fread(data, 1, cfg.numd << 2, file);
 
-		fclose(file);
-
 		if (n_data != (size_t)(cfg.numd << 2)) {
 			nvme_show_error("failed to read controller state data %s", libnvme_strerror(errno));
 			return -errno;
-- 
2.25.1




More information about the Linux-nvme mailing list