Skip to content

Commit

Permalink
migration: Plug memory leak on HMP migrate error path
Browse files Browse the repository at this point in the history
hmp_migrate() leaks @caps when qmp_migrate() fails.  Plug the leak
with g_autoptr().

Fixes: 967f2de (migration: Implement MigrateChannelList to hmp migration flow.) v8.2.0-rc0
Fixes: CID 1533125
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Link: https://lore.kernel.org/r/20240117140722.3979657-1-armbru@redhat.com
[peterx: fix CID number as reported by Peter Maydell]
Signed-off-by: Peter Xu <peterx@redhat.com>
  • Loading branch information
Markus Armbruster authored and xzpeter committed Jan 29, 2024
1 parent 73b4987 commit 918f620
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions migration/migration-hmp-cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
bool resume = qdict_get_try_bool(qdict, "resume", false);
const char *uri = qdict_get_str(qdict, "uri");
Error *err = NULL;
MigrationChannelList *caps = NULL;
g_autoptr(MigrationChannelList) caps = NULL;
g_autoptr(MigrationChannel) channel = NULL;

if (inc) {
Expand All @@ -789,8 +789,6 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
return;
}

qapi_free_MigrationChannelList(caps);

if (!detach) {
HMPMigrationStatus *status;

Expand Down

0 comments on commit 918f620

Please sign in to comment.