]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix possible memory leak in phyp_driver.c
authorPavel Hrdina <phrdina@redhat.com>
Mon, 13 Jan 2014 13:48:40 +0000 (14:48 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 15 Jan 2014 10:11:34 +0000 (11:11 +0100)
There could be a memory leak caused by "managed_system" string, if any
error occurs before "managed_system" is assigned into
"phyp_driver->managed_system". The "managed_system" string wouldn't be
freed at all. The better way is to free the "managed_system" instead
of the one assigned in the "phyp_driver".

This has been found by coverity.

Pointed out by John, that the "phyp_driver->xmlopt" needs to be
unreferenced as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
src/phyp/phyp_driver.c

index 32165ed201d983a6b96ed098bf3f38c02e187a44..3ff3006f988134fe4c522d1ddbc58412ab6eaa2d 100644 (file)
@@ -1153,9 +1153,11 @@ phypConnectOpen(virConnectPtr conn,
     return VIR_DRV_OPEN_SUCCESS;
 
 failure:
+    VIR_FREE(managed_system);
+
     if (phyp_driver != NULL) {
         virObjectUnref(phyp_driver->caps);
-        VIR_FREE(phyp_driver->managed_system);
+        virObjectUnref(phyp_driver->xmlopt);
         VIR_FREE(phyp_driver);
     }