
On 05/08/2013 03:45 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
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@redhat.com> ---
/* 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