# HG changeset patch # User Keir Fraser # Date 1260522075 0 # Node ID 63ff27b3b07ad884613e32fe06909bb20e354378 # Parent f61303bcc3ac6fbf67b9f92183fecc4b6f26d324 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 Acked-by: Stefano Stabellini diff -r f61303bcc3ac -r 63ff27b3b07a extras/mini-os/lib/xs.c --- a/extras/mini-os/lib/xs.c Fri Dec 11 09:00:40 2009 +0000 +++ b/extras/mini-os/lib/xs.c Fri Dec 11 09:01:15 2009 +0000 @@ -49,6 +49,7 @@ void *xs_read(struct xs_handle *h, xs_tr 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_tr msg = xenbus_write(t, path, value); if (msg) { printk("xs_write(%s): %s\n", path, msg); + free(msg); return false; } return true;