From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYuP9-0002x4-AJ for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:48:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYuP8-0003ug-Dz for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:48:23 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:34423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYuP8-0003uU-23 for qemu-devel@nongnu.org; Thu, 25 Feb 2016 06:48:22 -0500 Received: by mail-wm0-x232.google.com with SMTP id b205so28062314wmb.1 for ; Thu, 25 Feb 2016 03:48:21 -0800 (PST) Date: Thu, 25 Feb 2016 12:48:19 +0100 From: Jiri Pirko Message-ID: <20160225114819.GA2159@nanopsycho.orion> 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> <20160225113158.GC23099@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160225113158.GC23099@stefanha-x1.localdomain> 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: Stefan Hajnoczi 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 Thu, Feb 25, 2016 at 12:31:58PM CET, stefanha@gmail.com wrote: >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 */ >> >> >> >> r->worlds[ROCKER_WORLD_TYPE_OF_DPA] = of_dpa_world_alloc(r); >> >> - r->world_dflt = r->worlds[ROCKER_WORLD_TYPE_OF_DPA]; >> >> + >> >> + if (!r->world_name) { >> >> + r->world_name = g_strdup(world_name(r->worlds[ROCKER_WORLD_TYPE_OF_DPA])); >> >> + } >> >> + >> >> + r->world_dflt = 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. >> >> I did the same what is done with "r->name = g_strdup(ROCKER)" >> >> 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.) Will fix and send v2. Thanks.