Re: [PATCH v2] Delete udevFreeIfaceDef function in udev interface driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/08/2013 03:45 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> The udevFreeIfaceDef function in the udev interface driver
> just duplicates code from virInterfaceDefFree. Delete it
> and call the standard API instead.
> 
> Fix the udevGetIfaceDefVlan method so that it doesn't
> store pointers to the middle of a malloc'd memory
> area.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---

>  
>      /* Set the VLAN specifics */
> -    ifacedef->data.vlan.tag = vid;
> -    ifacedef->data.vlan.devname = vlan_parent_dev;
> +    if (!(ifacedef->data.vlan.tag = strdup(vid + 1)))
> +        goto no_memory;

VIR_STRDUP exists in the tree now, if you'd like to start using it
(instead of making Michal touch up yet another spot when he finally
turns on the syntax-check rule at the end of his series).

> +    if (!(ifacedef->data.vlan.devname = strndup(name,
> +                                                (vid - name))))
> +        goto no_memory;

Same for VIR_STRNDUP.

>  
>      return 0;
>  
> -cleanup:
> -    VIR_FREE(vlan_parent_dev);
> +no_memory:
> +    VIR_FREE(ifacedef->data.vlan.tag);
> +    VIR_FREE(ifacedef->data.vlan.devname);

Also, by using VIR_STRDUP, I wouldn't have to call you on your missing
virReportOOMError() :)

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]