[libvirt] [PATCH v2] Resolve FORWARD_NULL errors found by Coverity

Reworked the usbFreeDevice changes to allow NULL to be passed and added usbFreeDevice to the cfg.mk file. John Ferlan (1): util: Check for NULL 'dev' on input to usbFreeDevice cfg.mk | 1 + src/util/virusb.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) -- 1.7.11.7

Added 'usbFreeDevice' to the useless_free_options list in cfg.mk --- cfg.mk | 1 + src/util/virusb.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cfg.mk b/cfg.mk index f9270b0..ab163af 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 c09f6da..1ec5f45 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 * -- 1.7.11.7

On Tue, Jan 08, 2013 at 07:42:26AM -0500, John Ferlan wrote:
Added 'usbFreeDevice' to the useless_free_options list in cfg.mk --- cfg.mk | 1 + src/util/virusb.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/cfg.mk b/cfg.mk index f9270b0..ab163af 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 c09f6da..1ec5f45 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 *
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 01/08/2013 05:45 AM, Daniel P. Berrange wrote:
On Tue, Jan 08, 2013 at 07:42:26AM -0500, John Ferlan wrote:
Added 'usbFreeDevice' to the useless_free_options list in cfg.mk --- cfg.mk | 1 + src/util/virusb.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
ACK
Pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/08/13 13:42, John Ferlan wrote:
Reworked the usbFreeDevice changes to allow NULL to be passed and added usbFreeDevice to the cfg.mk file.
John Ferlan (1): util: Check for NULL 'dev' on input to usbFreeDevice
cfg.mk | 1 + src/util/virusb.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
We usually don't use cover-letters for single patches. For extra explanation you may use the space after the three dashes and before the changed file list (after you format the patch). That patch can be later applied without the text after dashes and you save a email. Peter
participants (4)
-
Daniel P. Berrange
-
Eric Blake
-
John Ferlan
-
Peter Krempa