WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Xen

xen-devel

[Top] [All Lists]

Re: [Xen-devel] [PATCH 1 of 5] libxl: fix memory management in "xl netwo

To: Dave Scott <Dave.Scott@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 1 of 5] libxl: fix memory management in "xl network-attach"
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: 2011年3月29日 09:30:15 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: 2011年3月29日 01:30:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <85361e3dab12827c6321.1301315195@ely >
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <patchbomb.1301315194@ely > <85361e3dab12827c6321.1301315195@ely >
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Mon, 2011年03月28日 at 13:26 +0100, Dave Scott wrote:
> # HG changeset patch
> # User David Scott <dave.scott@xxxxxxxxxxxxx>
> # Date 1301314652 -3600
> # Node ID 85361e3dab12827c6321931c9e09d02fb22578ee
> # Parent a65612bcbb921e98a8843157bf365e4ab16e8144
> libxl: fix memory management in "xl network-attach"
>
> The libxl_device_nic struct has strings which are initially strdup()ed
> and then free()ed in libxl_device_nic_destroy(). In the
> "network-attach" parser we need to free() the existing string and
> strdup((*argv) + N), rather than just copying the pointer.
Ideally we would have a parsing routine shared with the cfg file parser
but for now this is a definite improvement:
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
>
> Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>
>
> diff -r a65612bcbb92 -r 85361e3dab12 tools/libxl/xl_cmdimpl.c
> --- a/tools/libxl/xl_cmdimpl.c Fri Mar 25 09:03:17 2011 +0000
> +++ b/tools/libxl/xl_cmdimpl.c Mon Mar 28 13:17:32 2011 +0100
> @@ -4277,12 +4277,14 @@
> nic.mac[i] = val;
> }
> } else if (!strncmp("bridge=", *argv, 7)) {
> - nic.bridge = (*argv) + 7;
> + free(nic.bridge);
> + nic.bridge = strdup((*argv) + 7);
> } else if (!strncmp("ip=", *argv, 3)) {
> free(nic.ip);
> nic.ip = strdup((*argv) + 3);
> } else if (!strncmp("script=", *argv, 6)) {
> - nic.script = (*argv) + 6;
> + free(nic.script);
> + nic.script = strdup((*argv) + 6);
> } else if (!strncmp("backend=", *argv, 8)) {
> if(libxl_name_to_domid(&ctx, ((*argv) + 8), &val)) {
> fprintf(stderr, "Specified backend domain does not exist, 
> defaulting to Dom0\n");
> @@ -4290,9 +4292,11 @@
> }
> nic.backend_domid = val;
> } else if (!strncmp("vifname=", *argv, 8)) {
> - nic.ifname = (*argv) + 8;
> + free(nic.ifname);
> + nic.ifname = strdup((*argv) + 8);
> } else if (!strncmp("model=", *argv, 6)) {
> - nic.model = (*argv) + 6;
> + free(nic.model);
> + nic.model = strdup((*argv) + 6);
> } else if (!strncmp("rate=", *argv, 5)) {
> } else if (!strncmp("accel=", *argv, 6)) {
> } else {
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
Previous by Date: Re: [Xen-devel] Dom0 pvops (2.6.32.35 xen/next-2.6.32.x) crashes at boot time (balloon_init OOPS #0002) , Andy Georges
Next by Date: Re: [Xen-devel] [PATCH 2 of 5] tools: ocaml: move the nic_info record into a module to the field labels live in a separate namespace , Ian Campbell
Previous by Thread: Re: [Xen-devel] [PATCH 1 of 5] libxl: fix memory management in "xl network-attach" , Stefano Stabellini
Next by Thread: [Xen-devel] [PATCH 4 of 5] tools: ocaml: add NIC QoS parameters to the ocaml libxl interface , David Scott
Indexes: [Date] [Thread] [Top] [All Lists]

Copyright ©, Citrix Systems Inc. All rights reserved. Legal and Privacy
Citrix This site is hosted by Citrix

AltStyle によって変換されたページ (->オリジナル) /