From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXusZ-0003Sy-II for qemu-devel@nongnu.org; Mon, 22 Feb 2016 13:06:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXusY-0003mW-OS for qemu-devel@nongnu.org; Mon, 22 Feb 2016 13:06:39 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:33490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXusY-0003lT-FI for qemu-devel@nongnu.org; Mon, 22 Feb 2016 13:06:38 -0500 Received: by mail-wm0-x232.google.com with SMTP id g62so168456092wme.0 for ; Mon, 22 Feb 2016 10:06:38 -0800 (PST) Date: Mon, 22 Feb 2016 19:06:34 +0100 From: Jiri Pirko Message-ID: <20160222180633.GB2274@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160222175150.GD10927@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 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.