[PATCH 1/2] migration: Fix cleanup of iochannel in file migration

Fabiano Rosas posted 2 patches 3 months, 3 weeks ago
[PATCH 1/2] migration: Fix cleanup of iochannel in file migration
Posted by Fabiano Rosas 3 months, 3 weeks ago
The QIOChannelFile object already has its reference decremented by
g_autoptr. Trying to unref an extra time causes:

ERROR:../qom/object.c:1241:object_unref: assertion failed: (obj->ref > 0)

Fixes: a701c03dec ("migration: Drop reference to QIOChannel if file seeking fails")
Fixes: 6d3279655a ("migration: Fix file migration with fdset")
Reported-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/file.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/migration/file.c b/migration/file.c
index db870f2cf0..6451a21c86 100644
--- a/migration/file.c
+++ b/migration/file.c
@@ -112,7 +112,6 @@ void file_start_outgoing_migration(MigrationState *s,
         error_setg_errno(errp, errno,
                          "failed to truncate migration file to offset %" PRIx64,
                          offset);
-        object_unref(OBJECT(fioc));
         return;
     }
 
@@ -120,7 +119,6 @@ void file_start_outgoing_migration(MigrationState *s,
 
     ioc = QIO_CHANNEL(fioc);
     if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) {
-        object_unref(OBJECT(fioc));
         return;
     }
     qio_channel_set_name(ioc, "migration-file-outgoing");
-- 
2.35.3
Re: [PATCH 1/2] migration: Fix cleanup of iochannel in file migration
Posted by Peter Xu 3 months, 3 weeks ago
On Thu, Aug 01, 2024 at 02:41:00PM -0300, Fabiano Rosas wrote:
> The QIOChannelFile object already has its reference decremented by
> g_autoptr. Trying to unref an extra time causes:
> 
> ERROR:../qom/object.c:1241:object_unref: assertion failed: (obj->ref > 0)
> 
> Fixes: a701c03dec ("migration: Drop reference to QIOChannel if file seeking fails")
> Fixes: 6d3279655a ("migration: Fix file migration with fdset")
> Reported-by: Jim Fehlig <jfehlig@suse.com>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>

Ouch..

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu