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 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] xl: fix leak in libxl_wait_for_backend()

To: "Marc - A. Dahlhaus" <mad@xxxxxx>
Subject: Re: [Xen-devel] [PATCH] xl: fix leak in libxl_wait_for_backend()
From: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Date: Tue, 17 Aug 2010 14:08:01 +0100
Cc: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 17 Aug 2010 06:13:33 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1282050514.11973.3.camel@marc>
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>
References: <1282049021.18490.477.camel@xxxxxxxxxxxxxxxxxxxxxx> <1282050514.11973.3.camel@marc>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Tue, 2010-08-17 at 14:08 +0100, Marc - A. Dahlhaus wrote:
> Am Dienstag, den 17.08.2010, 13:43 +0100 schrieb Gianni Tedesco:
> > Another one introduced since the gc patch-set.
> > 
> > Signed-off-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
> > 
> --8<--
> > +out:
> >      libxl_free_all(&gc);
> >      return -1;
> This needs to be rc instead of -1 then?
> 
> Marc

Of course, yes, how foolish of me.
8<----------------------------------------------------------
Another one introduced since the gc patch-set.

Signed-off-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>

diff -r f353f1ac38f6 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Tue Aug 17 12:45:44 2010 +0100
+++ b/tools/libxl/libxl_device.c        Tue Aug 17 14:12:53 2010 +0100
@@ -457,6 +457,7 @@ int libxl_wait_for_backend(libxl_ctx *ct
     unsigned int len;
     char *p;
     char *path = libxl_sprintf(&gc, "%s/state", be_path);
+    int rc = -1;
 
     while (watchdog > 0) {
         p = xs_read(ctx->xsh, XBT_NULL, path, &len);
@@ -468,10 +469,11 @@ int libxl_wait_for_backend(libxl_ctx *ct
                 XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to access backend %s",
                        be_path);
             }
-            return -1;
+            goto out;
         } else {
             if (!strcmp(p, state)) {
-                return 0;
+                rc = 0;
+                goto out;
             } else {
                 usleep(100000);
                 watchdog--;
@@ -479,7 +481,8 @@ int libxl_wait_for_backend(libxl_ctx *ct
         }
     }
     XL_LOG(ctx, XL_LOG_ERROR, "Backend %s not ready", be_path);
+out:
     libxl_free_all(&gc);
-    return -1;
+    return rc;
 }
 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>