From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW0rL-00039j-Gb for qemu-devel@nongnu.org; Mon, 22 Sep 2014 06:28:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XW0rF-0004ht-Ch for qemu-devel@nongnu.org; Mon, 22 Sep 2014 06:28:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW0rF-0004hK-3f for qemu-devel@nongnu.org; Mon, 22 Sep 2014 06:28:37 -0400 Date: Mon, 22 Sep 2014 11:28:23 +0100 From: Stefan Hajnoczi Message-ID: <20140922102823.GC12513@stefanha-thinkpad.redhat.com> References: <1411203352-15264-1-git-send-email-stefanha@redhat.com> <33183CC9F5247A488A2544077AF1902086DD8B63@SZXEMA503-MBS.china.huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0vzXIDBeUiKkjNJl" Content-Disposition: inline In-Reply-To: <33183CC9F5247A488A2544077AF1902086DD8B63@SZXEMA503-MBS.china.huawei.com> Subject: Re: [Qemu-devel] [PATCH] blkdebug: show an error for invalid event names List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: Kevin Wolf , Fam Zheng , "qemu-devel@nongnu.org" , Max Reitz --0vzXIDBeUiKkjNJl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Sep 20, 2014 at 09:32:35AM +0000, Gonglei (Arei) wrote: > > @@ -315,10 +320,21 @@ static int read_config(BDRVBlkdebugState *s, const > > char *filename, > >=20 > > d.s =3D s; > > d.action =3D ACTION_INJECT_ERROR; > > - qemu_opts_foreach(&inject_error_opts, add_rule, &d, 0); > > + d.errp =3D &local_err; > > + qemu_opts_foreach(&inject_error_opts, add_rule, &d, 1); > > + if (local_err) { > > + error_propagate(errp, local_err); > > + ret =3D -EINVAL; > > + goto fail; > > + } > >=20 >=20 > If this check failed, it don't need to reset &set_state_opts. Setting up the rules has failed and we need to free the QemuOpts which were built up in this function. If we don't free them then there is a memory leak. Why is it correct to avoid resetting set_state_opts? Stefan --0vzXIDBeUiKkjNJl Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUH/nHAAoJEJykq7OBq3PIaWgIAIruRi1O77hKgoa5eGFLyS6T 7oSSe3DToVt6lzrSIyvi6heZ1r0iSsLbyEIaWlD1Nz12ucCldDm0lMhYPM8YmFA3 k0O7X2gqd34yGoR9w0n5eIByG5yKb4XGVO96xmRcfZMxOvFZgrfwEAuDlEdmRUks edV/ldJBoNKFwJY22nJ/c7HAhf8moqIbgMZuDetrKkqqa9AGHI+NKi5ksoJ36Lkh mRq+ArrNsspL2advvlKdKYtbLkVdgKiwDcUWUoe8+eASLHylPUjMEYCGZB4GYNBl yxiBneqkvdf410w16uRZc174HjsXoNjOZBPwjC4awVGpKspE60x+enpRWr5yqpk= =fjQC -----END PGP SIGNATURE----- --0vzXIDBeUiKkjNJl--