]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Check for NULL 'dev' on input to usbFreeDevice
authorJohn Ferlan <jferlan@redhat.com>
Tue, 8 Jan 2013 12:42:26 +0000 (07:42 -0500)
committerEric Blake <eblake@redhat.com>
Tue, 8 Jan 2013 15:45:40 +0000 (08:45 -0700)
Added 'usbFreeDevice' to the useless_free_options list in cfg.mk

cfg.mk
src/util/virusb.c

diff --git a/cfg.mk b/cfg.mk
index f9270b0eb6aefcefbb639c57da17e7b7502274b9..ab163af338ec63a470bd506c55742180fa590149 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -98,6 +98,7 @@ useless_free_options =                                \
   --name=qemuMigrationCookieFree                \
   --name=qemuMigrationCookieGraphicsFree        \
   --name=sexpr_free                            \
+  --name=usbFreeDevice                          \
   --name=virBandwidthDefFree                   \
   --name=virBitmapFree                          \
   --name=virCPUDefFree                         \
index c09f6da366abcf84cd79f6e6c3d19745a41f2d73..1ec5f4598fa51dd21614d15914888a0d77cd0c71 100644 (file)
@@ -356,6 +356,8 @@ usbGetDevice(unsigned int bus,
 void
 usbFreeDevice(usbDevice *dev)
 {
+    if (!dev)
+        return;
     VIR_DEBUG("%s %s: freeing", dev->id, dev->name);
     VIR_FREE(dev->path);
     VIR_FREE(dev);
@@ -496,8 +498,7 @@ usbDeviceListDel(usbDeviceList *list,
                  usbDevice *dev)
 {
     usbDevice *ret = usbDeviceListSteal(list, dev);
-    if (ret)
-        usbFreeDevice(ret);
+    usbFreeDevice(ret);
 }
 
 usbDevice *