debuggers.hg

changeset 20669:63ff27b3b07a

mini-os: Fix memory leaks in xs_read() and xs_write()

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>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Dec 11 09:01:15 2009 +0000 (2009-12-11)
parents f61303bcc3ac
children 90a6dd880ddf
files extras/mini-os/lib/xs.c
line diff
     1.1 --- a/extras/mini-os/lib/xs.c	Fri Dec 11 09:00:40 2009 +0000
     1.2 +++ b/extras/mini-os/lib/xs.c	Fri Dec 11 09:01:15 2009 +0000
     1.3 @@ -49,6 +49,7 @@ void *xs_read(struct xs_handle *h, xs_tr
     1.4      msg = xenbus_read(t, path, &value);
     1.5      if (msg) {
     1.6  	printk("xs_read(%s): %s\n", path, msg);
     1.7 +	free(msg);
     1.8  	return NULL;
     1.9      }
    1.10  
    1.11 @@ -69,6 +70,7 @@ bool xs_write(struct xs_handle *h, xs_tr
    1.12      msg = xenbus_write(t, path, value);
    1.13      if (msg) {
    1.14  	printk("xs_write(%s): %s\n", path, msg);
    1.15 +	free(msg);
    1.16  	return false;
    1.17      }
    1.18      return true;