On Mon, Jan 25, 2010 at 04:46:02PM +0100, Jim Meyering wrote:
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(a)redhat.com>
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;
--
ACK
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|