util: Check for NULL 'dev' on input to usbFreeDevice

Added 'usbFreeDevice' to the useless_free_options list in cfg.mk
This commit is contained in:
John Ferlan 2013-01-08 07:42:26 -05:00 committed by Eric Blake
parent 0a5eaf0d59
commit fef8d1a010
2 changed files with 4 additions and 2 deletions

1
cfg.mk
View File

@ -98,6 +98,7 @@ useless_free_options = \
--name=qemuMigrationCookieFree \
--name=qemuMigrationCookieGraphicsFree \
--name=sexpr_free \
--name=usbFreeDevice \
--name=virBandwidthDefFree \
--name=virBitmapFree \
--name=virCPUDefFree \

View 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,7 +498,6 @@ usbDeviceListDel(usbDeviceList *list,
usbDevice *dev)
{
usbDevice *ret = usbDeviceListSteal(list, dev);
if (ret)
usbFreeDevice(ret);
}