Received: from eggs.gnu.org ([2001:4830:134:3::10]:41093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvgTi-0004pM-28 for qemu-devel@nongnu.org; Mon, 09 Nov 2015 02:02:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvgTd-0006ph-1k for qemu-devel@nongnu.org; Mon, 09 Nov 2015 02:02:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvgTc-0006pb-Qm for qemu-devel@nongnu.org; Mon, 09 Nov 2015 02:02:52 -0500 Date: Mon, 9 Nov 2015 08:04:45 +0100 From: Peter Krempa Message-ID: <20151109070445.GF3391301@andariel.pipo.sk> References: <1446727026-18094-1-git-send-email-prasanna.kalever@redhat.com> <1446727026-18094-2-git-send-email-prasanna.kalever@redhat.com> <1677110309.4230186.1446727550535.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jt0yj30bxbg11sci" Content-Disposition: inline In-Reply-To: <1677110309.4230186.1446727550535.JavaMail.zimbra@redhat.com> Subject: Re: [Qemu-devel] [PATCH 3/3] block/gluster: add support for multiple gluster servers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Prasanna Kumar Kalever Cc: kwolf@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, deepakcs@redhat.com, bharata@linux.vnet.ibm.com, rtalur@redhat.com --jt0yj30bxbg11sci Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 05, 2015 at 07:45:50 -0500, Prasanna Kumar Kalever wrote: > On Thursday, November 5, 2015 6:07:06 PM, Prasanna Kumar Kalever wrote: > > This patch adds a way to specify multiple volfile servers to the gluster > > block backend of QEMU with tcp|rdma transport types and their port numb= ers. > >=20 > > Problem: > >=20 > > Currently VM Image on gluster volume is specified like this: >=20 [...] > > @@ -345,7 +676,7 @@ static int qemu_gluster_open(BlockDriverState *bs, = QDict > > *options, > > =20 > > out: > > qemu_opts_del(opts); > > - qemu_gluster_gconf_free(gconf); > > + qapi_free_BlockdevOptionsGluster(gconf); >=20 > Can some one help me please ? > This leads to crash in the second iteration i.e. while freeing "gconf->se= rvers->next->value" So, prior to this you allocate a array of the data structures as: + gsconf =3D g_new0(GlusterServer, num_servers); + + ptr =3D qemu_opt_get(opts, GLUSTER_OPT_VOLUME); + if (!ptr) { + error_setg(&local_err, "Error: qemu_gluster: please provide 'volum= e' " + "option"); + goto out; =20 + } Then you use the following code to fill the linked list: + if (gconf->servers =3D=3D NULL) { + gconf->servers =3D g_new0(GlusterServerList, 1); + gconf->servers->value =3D &gsconf[i]; So here you set the value. For a i of 0 the '&gsconf[i]' expression will be a pointer with equal address to 'gsconf'. For explanation: 'gsconf[i]' can be written as '*(gsconf + i)', so '&gsconf[i]' becomes basically '&(*(gsconf + i))' This can be also simplified to: 'gsconf + i'. For a i of 0 this becomes the same pointer as 'gsconf' And once you use that with free(), the whole gsconf array will be freed. All the other pointers that you've filled to the linked list become invalid, since they were pointing into the same array that was completely freed in the first iteration. Peter --jt0yj30bxbg11sci Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWQEWNAAoJEDbsFqzQGGgrFlUP/RdGfV9KgVk39pgYYYFph90B YsBHdIO41QsI4NTNIiYE8UuTNLwLQrQbjgYwkTBCafjfXDZNgczCCvIZ6dxdMrOf ma30MuIKkJYktXiTR8t+jshLs8mv9xBBMZJSfOQwnMUfpNyhZpf75m3ZIwacsRXL eaU9NvY8Lbq2rDaCL0iL+GiPw+NVb2HtvhS/Q5ImKFzxmQE0Vft32Mynrbw/ln7l /plclaRpN5Hclzm+bN/KgjoJPHQ2+6lUhD0KSiJB2zQz6zhhaCgqJH+cC3tuI1Vw Pfk51lobFgcxlDxTysJ9tZp6uilhRX7RKAIqlpYo04IwJcConav7HyrRHrEwYPMX /6Vl1Ifo97AKPXx8sizkEAx/ljNesUw4AYsPzjQpyT/QL/SVpL1CkHJpJj5bx7Us B3bxZ+XrXeBsbt4EjmWAbUhdalVn3B4DSwlPnfCKOglKHxvptLFX1N4gQGD9gJ7X G0LZH0zMcVAMlWVSPTXUWW2cMZ5foCw+8SD3PLrHoae0QCll6cqOPVyJBNlpBsU+ 1tCZ9zJHbnUSOm8m5GQiNIv7Y1WdIDv0OoQ70NjjTrZKv0jC9Z513ijM0qBS0oq5 BL9i9rlsR0tgOcwUbscMbaUCJNXPYAwZfVTLrcAgMZPGw2aTuZD7s4cHwTrCplmr XmdIRtsjXUj/UtdTyXJq =0/I2 -----END PGP SIGNATURE----- --jt0yj30bxbg11sci--