From: John Ferlan Date: Tue, 8 Jan 2013 12:42:26 +0000 (-0500) Subject: util: Check for NULL 'dev' on input to usbFreeDevice X-Git-Tag: v1.0.2-rc1~250 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fef8d1a010f78fa524617fbd213b08ab10dbef6d;p=thirdparty%2Flibvirt.git util: Check for NULL 'dev' on input to usbFreeDevice Added 'usbFreeDevice' to the useless_free_options list in cfg.mk --- diff --git a/cfg.mk b/cfg.mk index f9270b0eb6..ab163af338 100644 --- 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 \ diff --git a/src/util/virusb.c b/src/util/virusb.c index c09f6da366..1ec5f4598f 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -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 *