qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 3/3] block/gluster: add support for multiple glu


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 3/3] block/gluster: add support for multiple gluster servers
Date: Mon, 9 Nov 2015 14:11:19 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/09/2015 02:40 AM, Prasanna Kumar Kalever wrote:

>>> Can some one help me please ?
>>> This leads to crash in the second iteration i.e. while freeing
>>> "gconf->servers->next->value"
>>
>> So, prior to this you allocate a array of the data structures as:
>>
>> +    gsconf = g_new0(GlusterServer, num_servers);

This is wrong. When using GlusterServerList, you call
g_new0(GlusterServer, 1) once per element of the list, linking the list
together incrementally, instead of trying to array-allocate the whole
list at once.

>> Then you use the following code to fill the linked list:
>>
>> +      if (gconf->servers == NULL) {
>> +            gconf->servers = g_new0(GlusterServerList, 1);
>> +            gconf->servers->value = &gsconf[i];

Here is where you should be allocating value one element at a time,
rather than trying to point it into pre-allocated storage.

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]