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

[libvirt] [PATCH 12/14] parallels: Resolve some resource leaks



Be sure to VIR_FREE(accel) and moved virDomainVideoDefFree() within no_memory
label to be consistent

Resolve resource leak in parallelsApplyIfaceParams() when the 'oldnet' is
allocated locally.
---
 src/parallels/parallels_driver.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 6f33080..bf27e54 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -304,8 +304,9 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
 
 no_memory:
     virReportOOMError();
-cleanup:
+    VIR_FREE(accel);
     virDomainVideoDefFree(video);
+cleanup:
     return -1;
 }
 
@@ -1812,58 +1813,58 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
     if (!create && oldnet->type != newnet->type) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Changing network type is not supported"));
-        return -1;
+        goto error;
     }
 
     if (!STREQ_NULLABLE(oldnet->model, newnet->model)) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Changing network device model is not supported"));
-        return -1;
+        goto error;
     }
 
     if (!STREQ_NULLABLE(oldnet->data.network.portgroup,
                         newnet->data.network.portgroup)) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Changing network portgroup is not supported"));
-        return -1;
+        goto error;
     }
 
     if (!virNetDevVPortProfileEqual(oldnet->virtPortProfile,
                                     newnet->virtPortProfile)) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Changing virtual port profile is not supported"));
-        return -1;
+        goto error;
     }
 
     if (newnet->tune.sndbuf_specified) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Setting send buffer size is not supported"));
-        return -1;
+        goto error;
     }
 
     if (!STREQ_NULLABLE(oldnet->script, newnet->script)) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Setting startup script is not supported"));
-        return -1;
+        goto error;
     }
 
     if (!STREQ_NULLABLE(oldnet->filter, newnet->filter)) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Changing filter params is not supported"));
-        return -1;
+        goto error;
     }
 
     if (newnet->bandwidth != NULL) {
         virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                        _("Setting bandwidth params is not supported"));
-        return -1;
+        goto error;
     }
 
     for (i = 0; i < sizeof(newnet->vlan); i++) {
         if (((char *)&newnet->vlan)[i] != 0) {
             virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
                            _("Setting vlan params is not supported"));
-            return -1;
+            goto error;
         }
     }
 
@@ -1905,15 +1906,22 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
         is_changed = true;
     }
 
+    if (create)
+        VIR_FREE(oldnet);
+
     if (!create && !is_changed) {
         /* nothing changed - no need to run prlctl */
         return 0;
     }
 
     if (virCommandRun(cmd, NULL))
-        return -1;
+        goto error;
 
     return 0;
+error:
+    if (create)
+        VIR_FREE(oldnet);
+    return -1;
 }
 
 static int
-- 
1.7.11.7


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