[libvirt] [PATCH] openvz_driver.c: avoid leak on OOM error path

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

 



It looks like openvzFreeDriver cannot call VIR_FREE on its buffer
argument, because of the use in the function that just happens to
be a few lines below.  These are the only two uses of openvzFreeDriver.


>From 0a616cd03cca9c9d89f23dadd52cd23c30789aca Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Mon, 15 Feb 2010 18:33:38 +0100
Subject: [PATCH] openvz_driver.c: avoid leak on OOM error path

* src/openvz/openvz_driver.c (openvzOpen): Free "driver" buffer
upon failure.
---
 src/openvz/openvz_driver.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 68d0398..3a8a82f 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1245,22 +1245,23 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
         goto cleanup;

     if (openvzExtractVersion(conn, driver) < 0)
         goto cleanup;

     conn->privateData = driver;

     return VIR_DRV_OPEN_SUCCESS;

 cleanup:
     openvzFreeDriver(driver);
+    VIR_FREE(driver);
     return VIR_DRV_OPEN_ERROR;
 };

 static int openvzClose(virConnectPtr conn) {
     struct openvz_driver *driver = conn->privateData;

     openvzFreeDriver(driver);
     conn->privateData = NULL;

     return 0;
 }
--
1.7.0.181.g41533

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]