From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYu9O-0007tP-HG for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:32:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYu9K-00080j-6e for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:32:06 -0500 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:35232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYu9K-00080T-1F for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:32:02 -0500 Received: by mail-wm0-x22f.google.com with SMTP id c200so24044235wme.0 for ; Thu, 25 Feb 2016 03:32:01 -0800 (PST) Date: Thu, 25 Feb 2016 11:31:58 +0000 From: Stefan Hajnoczi Message-ID: <20160225113158.GC23099@stefanha-x1.localdomain> References: <1455876403-8575-1-git-send-email-jiri@resnulli.us> <1455876403-8575-4-git-send-email-jiri@resnulli.us> <20160222175150.GD10927@stefanha-x1.localdomain> <20160222180633.GB2274@nanopsycho.orion> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9Ek0hoCL9XbhcSqy" Content-Disposition: inline In-Reply-To: <20160222180633.GB2274@nanopsycho.orion> Subject: Re: [Qemu-devel] [patch qemu 3/3] rocker: allow user to specify rocker world by property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jiri Pirko Cc: daniel@iogearbox.net, prem@barefootnetworks.com, jasowang@redhat.com, qemu-devel@nongnu.org, parag.bhide@barefootnetworks.com, idosch@mellanox.com, sfeldma@gmail.com, eladr@mellanox.com, pbonzini@redhat.com, alexei.starovoitov@gmail.com --9Ek0hoCL9XbhcSqy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 22, 2016 at 07:06:34PM +0100, Jiri Pirko wrote: > Mon, Feb 22, 2016 at 06:51:50PM CET, stefanha@gmail.com wrote: > >On Fri, Feb 19, 2016 at 11:06:43AM +0100, Jiri Pirko wrote: > >> @@ -1297,7 +1310,18 @@ static int pci_rocker_init(PCIDevice *dev) > >> /* allocate worlds */ > >> =20 > >> r->worlds[ROCKER_WORLD_TYPE_OF_DPA] =3D of_dpa_world_alloc(r); > >> - r->world_dflt =3D r->worlds[ROCKER_WORLD_TYPE_OF_DPA]; > >> + > >> + if (!r->world_name) { > >> + r->world_name =3D g_strdup(world_name(r->worlds[ROCKER_WORLD_= TYPE_OF_DPA])); > >> + } > >> + > >> + r->world_dflt =3D rocker_world_type_by_name(r, r->world_name); > >> + if (!r->world_dflt) { > >> + fprintf(stderr, > >> + "rocker: requested world \"%s\" does not exist\n", > >> + r->world_name); > >> + return -EINVAL; > >> + } > > > >world_name is leaked here. Please use goto to run the appropriate > >cleanup code instead of returning directly. >=20 > I did the same what is done with "r->name =3D g_strdup(ROCKER)" >=20 > I assumed since this is a property, the caller core will take care of > that. You are right, the string properties will be freed by qdev property release. The return statement added by this patch still leaks r->worlds[ROCKER_WORLD_TYPE_OF_DPA] so goto err_world_alloc is needed. (pci_rocker_uninit() is not called if pci_rocker_init() fails.) --9Ek0hoCL9XbhcSqy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWzuYuAAoJEJykq7OBq3PItnQIAMZgBl776aSnDW1hBiN5wyY4 v4IdNFZ5TgdzzKt+nTpOslY6Ea0il5qiui2bKwWMinHYib3zIwGHFKBQ4OsC1gs4 ZsargmCiKEpxGsbSm/b1fzAW6Ty39j57JTvtXvkJyz4g0qoUyurXCJvcuGxCRVPv rBn7RHUHsn6C8ZoGBs3XHB+zjRodJoMTh1gyaTIZLxRNwEcqs2Qif4ms9N6Axv4q GOsOuTC5Xo+IUmY9ZXS+8ySdzS80iz5FmJKp0+1RfOG9f6+lJqFDsaqKnLDL/YRN 6VS0U0ag7mxVL44KQrwFnADWs+pSEDSkCUOVX8zoJh2jEjV2ENAV0XCU0q/5aI4= =QC30 -----END PGP SIGNATURE----- --9Ek0hoCL9XbhcSqy--