Skip to contentSkip to conversation

migration: Plug memory leak on HMP migrate error path

PATCH Applied Markus Armbruster 3 participants 5 messages Jan 17, 2024 – Jan 24, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration: Plug memory leak on HMP migrate error path

hmp_migrate() leaks @caps when qmp_migrate() fails. Plug the leak with g_autoptr().

Fixes 967f2de5c9ec (migration: Implement MigrateChannelList to hmp migration flow.) v8.2.0-rc0
Fixes CID 1533124
---
 migration/migration-hmp-cmds.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
migration/migration-hmp-cmds.c +1 -3
index 740a219aa4..99b49df5dd 100644
@@ -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) {
@@ -789,8 +789,6 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
         return;
     }
 
-    qapi_free_MigrationChannelList(caps);
-
     if (!detach) {
         HMPMigrationStatus *status;
 
Signature · 1 line
2.43.0
Applied
#1 lore raw
Quoted 6 lines · Markus Armbruster

hmp_migrate() leaks @caps when qmp_migrate() fails. Plug the leak with g_autoptr().

Fixes 967f2de5c9ec (migration: Implement MigrateChannelList to hmp migration flow.) v8.2.0-rc0
Fixes CID 1533124

queued, thanks!

Signature · 1 line
Peter Xu
#2 lore raw
In reply to Markus Armbruster
Quoted 6 lines · Markus Armbruster

hmp_migrate() leaks @caps when qmp_migrate() fails. Plug the leak with g_autoptr().

Fixes 967f2de5c9ec (migration: Implement MigrateChannelList to hmp migration flow.) v8.2.0-rc0
Fixes CID 1533124

Isn't this 1533125 ? 1533124 is a false positive in the migrate_mode() function.

Quoted 19 lines
---
 migration/migration-hmp-cmds.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
migration/migration-hmp-cmds.c +1 -1
index 740a219aa4..99b49df5dd 100644
@@ -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) {

migration/migration-hmp-cmds.c void hmp_migrate(Monitor *mon, const QDict *qdict) · line 793

Quoted 7 lines
migration/migration-hmp-cmds.c +0 -2
@@ -789,8 +789,6 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
         return;
     }
 
-    qapi_free_MigrationChannelList(caps);
-
     if (!detach) {
         HMPMigrationStatus *status;

thanks
-- PMM

#3 lore raw
Quoted 10 lines · Peter Maydell
Quoted 6 lines · Markus Armbruster

hmp_migrate() leaks @caps when qmp_migrate() fails. Plug the leak with g_autoptr().

Fixes 967f2de5c9ec (migration: Implement MigrateChannelList to hmp migration flow.) v8.2.0-rc0
Fixes CID 1533124

Isn't this 1533125 ? 1533124 is a false positive in the migrate_mode() function.

Indeed.. I fixed it in the staging branch (which will be in the final pull), thanks.

https://gitlab.com/peterx/qemu/-/commit/74278c11b980429916116baf0f742357af51ebb4

Signature · 1 line
Peter Xu
#4 lore raw
Quoted 11 lines · Peter Xu
Quoted 10 lines · Peter Maydell
Quoted 6 lines · Markus Armbruster

hmp_migrate() leaks @caps when qmp_migrate() fails. Plug the leak with g_autoptr().

Fixes 967f2de5c9ec (migration: Implement MigrateChannelList to hmp migration flow.) v8.2.0-rc0
Fixes CID 1533124

Isn't this 1533125 ? 1533124 is a false positive in the migrate_mode() function.

Yes.

Quoted 4 lines

Indeed.. I fixed it in the staging branch (which will be in the final pull), thanks.

https://gitlab.com/peterx/qemu/-/commit/74278c11b980429916116baf0f742357af51ebb4

Thanks for catching & fixing my typo!