From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1am2JH-0008PU-M6 for qemu-devel@nongnu.org; Fri, 01 Apr 2016 12:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1am2JG-0002Io-ND for qemu-devel@nongnu.org; Fri, 01 Apr 2016 12:52:35 -0400 References: <1459526222-30052-1-git-send-email-eblake@redhat.com> From: Max Reitz Message-ID: <56FEA749.7080509@redhat.com> Date: Fri, 1 Apr 2016 18:52:25 +0200 MIME-Version: 1.0 In-Reply-To: <1459526222-30052-1-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rE5JCEjFs9WSSCG720uxBqX28gVNBF6kK" Subject: Re: [Qemu-devel] [Qemu-block] [PATCH for-2.6] crypto: Avoid memory leak on failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: Kevin Wolf , "open list:Block layer core" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rE5JCEjFs9WSSCG720uxBqX28gVNBF6kK Content-Type: multipart/mixed; boundary="oUDsEWOBNUB80f0nKKKFD3GULHr437U6o" From: Max Reitz To: Eric Blake , qemu-devel@nongnu.org Cc: Kevin Wolf , "open list:Block layer core" Message-ID: <56FEA749.7080509@redhat.com> Subject: Re: [Qemu-block] [PATCH for-2.6] crypto: Avoid memory leak on failure References: <1459526222-30052-1-git-send-email-eblake@redhat.com> In-Reply-To: <1459526222-30052-1-git-send-email-eblake@redhat.com> --oUDsEWOBNUB80f0nKKKFD3GULHr437U6o Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 01.04.2016 17:57, Eric Blake wrote: > Commit 7836857 introduced a memory leak due to invalid use of > Error vs. visit_type_end(). If visiting the intermediate > members fails, we clear the error and unconditionally use > visit_end_struct() on the same error object; but if that > cleanup succeeds, we then skip the qapi_free call. It's not really a memleak. Due to skipping those conditional branches after the "out" label, a non-null value will be returned. In order to determine whether the function call failed, the callers of these functions do not use the errp value but the return value. Therefore, they will think the call succeeded when actually it did not. >=20 > Until a later patch adds visit_check_struct(), the only safe > approach is to use two separate error objects. >=20 > Signed-off-by: Eric Blake > --- > block/crypto.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) Anyway, thanks, applied to my block branch: https://github.com/XanClic/qemu/commits/block Max --oUDsEWOBNUB80f0nKKKFD3GULHr437U6o-- --rE5JCEjFs9WSSCG720uxBqX28gVNBF6kK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJW/qdJAAoJEDuxQgLoOKyt32IH/Ap8a3j2J3MBMN5p5EeNrMrB kSUWvQaYxJk6XGcL2DTygtsjnqDkA0ZZ5pTVBphQGYpuKm+yljSsz8vnX0KBF4hL 20+zkC5zIEBm9Xu1wtSe5bP7QkwBCrLPADso+YOyS0C8729TQZNSBEelEsLOB5Ww xxk2jpXQ/8flagw4eoagt/8FGO3EUJbh1VeUdjV0rH7ZNNPcB1kv6JDVX3kEEpTN jOCEZluWbxclUo6pnFIO/gULmPa9ZPBIwuMTi/FOS0HODLeLC59tQyGVW1zG+ONP 5bYnkH61NR6ysJ5xcT35kWYnj6AoRBn4WWYbUogWESUK+OlxNXemLtvnxevaH5E= =4CoH -----END PGP SIGNATURE----- --rE5JCEjFs9WSSCG720uxBqX28gVNBF6kK--