qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Prasanna Kumar Kalever <pkalever@redhat.com>,
	Peter Krempa <pkrempa@redhat.com>
Cc: kwolf@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org,
	deepakcs@redhat.com, bharata@linux.vnet.ibm.com,
	rtalur@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/3] block/gluster: add support for multiple gluster servers
Date: Mon, 9 Nov 2015 14:11:19 -0700	[thread overview]
Message-ID: <56410BF7.6050502@redhat.com> (raw)
In-Reply-To: <2024052690.6797703.1447062009061.JavaMail.zimbra@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

      reply	other threads:[~2015-11-09 21:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05 12:37 [Qemu-devel] [PATCH RFC 0/3] block/gluster: add support for multiple gluster servers Prasanna Kumar Kalever
2015-11-05 12:37 ` [Qemu-devel] [PATCH 3/3] " Prasanna Kumar Kalever
2015-11-05 12:45   ` Prasanna Kumar Kalever
2015-11-09  7:04     ` Peter Krempa
2015-11-09  9:40       ` Prasanna Kumar Kalever
2015-11-09 21:11         ` Eric Blake [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56410BF7.6050502@redhat.com \
    --to=eblake@redhat.com \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=deepakcs@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pkalever@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rtalur@redhat.com \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).