[libvirt] [PATCH] qemu: Fix domxml-to-native network model conversion

Cole Robinson crobinso at redhat.com
Sun Oct 21 20:47:13 UTC 2012


On 10/21/2012 05:59 AM, Peter Krempa wrote:
> On 10/21/12 04:49, Cole Robinson wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=636832
>> ---
>>   src/qemu/qemu_driver.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index feda4d9..c2ddba7 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -5362,6 +5362,13 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
>>       for (i = 0 ; i < def->nnets ; i++) {
>>           virDomainNetDefPtr net = def->nets[i];
>>           int bootIndex = net->info.bootIndex;
>> +        char *model = NULL;
>> +
>> +        if (net->model && !(model = strdup(net->model))) {
>> +            virReportOOMError();
>> +            goto cleanup;
>> +        }
> 
> In every control flow path the net structure gets memset'd to "0" thus leaking
> the model. It would be better if you stole the model name pointer and returned
> it to place after doing the needed stuff.
> 

Good point, sent a v2 fixing that issue.

- Cole




More information about the libvir-list mailing list