From 788e6cb25bbcdbef6fe945ac1533a40faf8f4293 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Mon, 13 Jan 2014 14:48:40 +0100 Subject: [PATCH] Fix possible memory leak in phyp_driver.c 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 Signed-off-by: John Ferlan --- src/phyp/phyp_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 32165ed201..3ff3006f98 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -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); } -- 2.39.5