Re: [PATCH 6/6] util: Plug memory leak on virNetDevMacVLanCreateWithVPortProfile() error path

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

 



On 12/01/2011 07:56 AM, Eric Blake wrote:
On 11/29/2011 10:57 PM, ajia@xxxxxxxxxx wrote:
From: Alex Jia<ajia@xxxxxxxxxx>

Detected by Coverity. Leak introduced in commit 90074ec.

Signed-off-by: Alex Jia<ajia@xxxxxxxxxx>
---
  src/util/virnetdevmacvlan.c |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 12fc411..80a9f80 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -582,6 +582,7 @@ create_name:
          virNetDevError(VIR_ERR_INTERNAL_ERROR,
                         _("cannot set bandwidth limits on %s"),
                         cr_ifname);
+        VIR_FORCE_CLOSE(rc);
          rc = -1;
          goto disassociate_exit;
Close, but this botches the case when !withTap (then, rc is 0 and you
just nuked stdin).  Here's what I'm squashing before pushing (and
hopefully Coverity isn't too confused because we overload rc to be
either an fd or just 0 depending on withTap):
Yeah, Coverity complains 'rc' is overwritten, it has a little confused for this.
diff --git i/src/util/virnetdevmacvlan.c w/src/util/virnetdevmacvlan.c
index 80a9f80..5e55b72 100644
--- i/src/util/virnetdevmacvlan.c
+++ w/src/util/virnetdevmacvlan.c
@@ -582,8 +582,10 @@ create_name:
          virNetDevError(VIR_ERR_INTERNAL_ERROR,
                         _("cannot set bandwidth limits on %s"),
                         cr_ifname);
-        VIR_FORCE_CLOSE(rc);
-        rc = -1;
+        if (withTap)
+            VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
+        else
+            rc = -1;
          goto disassociate_exit;
      }




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