[PATCH 1/2] ch_driver: Avoid driver double free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In one of my recent patches I made chStateInitialize() return
VIR_DRV_STATE_INIT_SKIPPED if CH_CMD doesn't exist. What I did
not realize back then was that chStateCleanup() would be called
twice. This is not a problem per-se because the function is a NOP
if driver is NULL. but the problem is that at the end it calls
plain g_free(driver) which does not set driver to NULL.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/ch/ch_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
index 7baacd7400..374f6e5542 100644
--- a/src/ch/ch_driver.c
+++ b/src/ch/ch_driver.c
@@ -826,7 +826,7 @@ static int chStateCleanup(void)
     virObjectUnref(ch_driver->caps);
     virObjectUnref(ch_driver->config);
     virMutexDestroy(&ch_driver->lock);
-    g_free(ch_driver);
+    g_clear_pointer(&ch_driver, g_free);
 
     return 0;
 }
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux