]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
mini-os: Fix memory leaks in xs_read() and xs_write()
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 11 Dec 2009 09:01:15 +0000 (09:01 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 11 Dec 2009 09:01:15 +0000 (09:01 +0000)
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@cn.fujitsu.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
lib/xs.c

index b654b0ee5d50c8495ccbbb3e29c3ab6f561eb1a2..6eced7034770876ec8f1d0a298537af083b4d7e4 100644 (file)
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -49,6 +49,7 @@ void *xs_read(struct xs_handle *h, xs_transaction_t t,
     msg = xenbus_read(t, path, &value);
     if (msg) {
        printk("xs_read(%s): %s\n", path, msg);
+       free(msg);
        return NULL;
     }
 
@@ -69,6 +70,7 @@ bool xs_write(struct xs_handle *h, xs_transaction_t t,
     msg = xenbus_write(t, path, value);
     if (msg) {
        printk("xs_write(%s): %s\n", path, msg);
+       free(msg);
        return false;
     }
     return true;