[libvirt] [PATCH] usbGetDevice: don't leak a "usbDevice" buffer on failure path

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

 



Here's another leak fix, although this one is only on a failure path:

>From a89551ecfcebfc3d45eff38923824a9590fe9f76 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Mon, 25 Jan 2010 16:44:13 +0100
Subject: [PATCH] usbGetDevice: don't leak a "usbDevice" buffer on failure path

* src/util/hostusb.c (usbGetDevice): Free "dev" when returning NULL.
---
 src/util/hostusb.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/util/hostusb.c b/src/util/hostusb.c
index 9a37103..f635ce5 100644
--- a/src/util/hostusb.c
+++ b/src/util/hostusb.c
@@ -171,8 +171,10 @@ usbGetDevice(virConnectPtr conn,

     if (vendor) {
         /* Look up bus.dev by vendor:product */
-        if (usbFindBusByVendor(conn, vendor, product, &bus, &devno) < 0)
+        if (usbFindBusByVendor(conn, vendor, product, &bus, &devno) < 0) {
+            VIR_FREE(dev);
             return NULL;
+        }
     }

     dev->bus     = bus;
--
1.7.0.rc0.127.gab8271

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