[PATCH] plugin/lm: avoid closing migration-send input twice
Kundan Kumar <[email protected]> Wed, 29 Jul 2026 14:42:41 +0530
| Newsgroups | org.infradead.lists.linux-nvme |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]>
---
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