]> xenbits.xensource.com Git - libvirt.git/commitdiff
ch: Don't leak ch_driver->chCaps
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 28 Nov 2023 15:35:22 +0000 (16:35 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 29 Nov 2023 07:54:14 +0000 (08:54 +0100)
During CH driver initialization (chStateInitialize()) the
driver's capabilities bitmap is allocated
(virCHCapsInitCHVersionCaps()), but corresponding free call is
missing in chStateCleanup().

And while at it, reorder calls to virObjectUnref() inside of
chStateCleanup() to be the reverse order of that in
chStateInitialize() so that it's easier to spot missing
free/unref call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/ch/ch_driver.c

index bd271fc0ee87d806b351a8e65f938fa4d830f65a..96de5044ac57b695170664d7b0088d260d966ea8 100644 (file)
@@ -850,10 +850,11 @@ static int chStateCleanup(void)
     if (ch_driver == NULL)
         return -1;
 
-    virObjectUnref(ch_driver->domains);
+    virBitmapFree(ch_driver->chCaps);
+    virObjectUnref(ch_driver->config);
     virObjectUnref(ch_driver->xmlopt);
     virObjectUnref(ch_driver->caps);
-    virObjectUnref(ch_driver->config);
+    virObjectUnref(ch_driver->domains);
     virMutexDestroy(&ch_driver->lock);
     g_clear_pointer(&ch_driver, g_free);