[libvirt] [PATCH 4/6] lxc: Check for non NULL usb prior to calling usbFreeDevice()

Daniel P. Berrange berrange at redhat.com
Mon Jan 7 18:28:20 UTC 2013


On Mon, Jan 07, 2013 at 12:09:32PM -0500, John Ferlan wrote:
> ---
>  src/lxc/lxc_driver.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 8050ce6..d4b4989 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -3468,7 +3468,8 @@ cleanup:
>      if (ret < 0 && created)
>          unlink(dstfile);
>  
> -    usbFreeDevice(usb);
> +    if (usb)
> +        usbFreeDevice(usb);
>      virCgroupFree(&group);
>      VIR_FREE(src);
>      VIR_FREE(dstfile);
> @@ -4022,7 +4023,8 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
>      ret = 0;
>  
>  cleanup:
> -    usbFreeDevice(usb);
> +    if (usb)
> +        usbFreeDevice(usb);
>      VIR_FREE(dst);
>      virCgroupFree(&group);
>      return ret;

NACK to this one. Can you change the 'usbFreeDevice' method to contain
a line

   if (!dev)
      return

so that it matches our preferred coding style of allowing NULLS to
'free()' like methods. Also then add that method to the variable
'useless_free_options' in cfg.mk

Regards,
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 :|




More information about the libvir-list mailing list