Skip to content

Commit 0284a2a

Browse files
elmarcodagrh
authored andcommitted
migration: fix QEMUFile leak
Spotted by ASAN while running: $ tests/migration-test -p /x86_64/migration/postcopy/recovery ================================================================= ==18034==ERROR: LeakSanitizer: detected memory leaks Direct leak of 33864 byte(s) in 1 object(s) allocated from: #0 0x7f3da7f31e50 in calloc (/lib64/libasan.so.5+0xeee50) #1 0x7f3da644441d in g_malloc0 (/lib64/libglib-2.0.so.0+0x5241d) #2 0x55af9db15440 in qemu_fopen_channel_input /home/elmarco/src/qemu/migration/qemu-file-channel.c:183 #3 0x55af9db15413 in channel_get_output_return_path /home/elmarco/src/qemu/migration/qemu-file-channel.c:159 #4 0x55af9db0d4ac in qemu_file_get_return_path /home/elmarco/src/qemu/migration/qemu-file.c:78 #5 0x55af9dad5e4f in open_return_path_on_source /home/elmarco/src/qemu/migration/migration.c:2295 #6 0x55af9dadb3bf in migrate_fd_connect /home/elmarco/src/qemu/migration/migration.c:3111 #7 0x55af9dae1bf3 in migration_channel_connect /home/elmarco/src/qemu/migration/channel.c:91 #8 0x55af9daddeca in socket_outgoing_migration /home/elmarco/src/qemu/migration/socket.c:108 #9 0x55af9e13d3db in qio_task_complete /home/elmarco/src/qemu/io/task.c:158 #10 0x55af9e13ca03 in qio_task_thread_result /home/elmarco/src/qemu/io/task.c:89 #11 0x7f3da643b1ca in g_idle_dispatch gmain.c:5535 Signed-off-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Reviewed-by: Peter Xu <[email protected]> Reviewed-by: Dr. David Alan Gilbert <[email protected]> Signed-off-by: Dr. David Alan Gilbert <[email protected]>
1 parent fc71e3e commit 0284a2a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

migration/migration.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,10 @@ static void *source_return_path_thread(void *opaque)
22802280
*/
22812281
if (postcopy_pause_return_path_thread(ms)) {
22822282
/* Reload rp, reset the rest */
2283-
rp = ms->rp_state.from_dst_file;
2283+
if (rp != ms->rp_state.from_dst_file) {
2284+
qemu_fclose(rp);
2285+
rp = ms->rp_state.from_dst_file;
2286+
}
22842287
ms->rp_state.error = false;
22852288
goto retry;
22862289
}

0 commit comments

Comments
 (0)