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

[Xen-devel] [PATCH] mini-os: Fix memory leaks in xs_read() and xs_write(

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] mini-os: Fix memory leaks in xs_read() and xs_write()
From: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>
Date: Thu, 10 Dec 2009 15:36:41 +0800
Cc:
Delivery-date: Wed, 09 Dec 2009 23:36:45 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 3.0a1 (Windows/2008050715)
xenbus_read() and xenbus_write() will allocate memory
for error message if any error occurs, this memory
should be freed.

Signed-off-by: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>

diff --git a/extras/mini-os/lib/xs.c b/extras/mini-os/lib/xs.c
--- a/extras/mini-os/lib/xs.c
+++ b/extras/mini-os/lib/xs.c
@@ -49,6 +49,7 @@
     msg = xenbus_read(t, path, &value);
     if (msg) {
        printk("xs_read(%s): %s\n", path, msg);
+       free(msg);
        return NULL;
     }
 
@@ -69,6 +70,7 @@
     msg = xenbus_write(t, path, value);
     if (msg) {
        printk("xs_write(%s): %s\n", path, msg);
+       free(msg);
        return false;
     }
     return true;



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

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