From: Keir Fraser Date: Fri, 11 Dec 2009 09:01:15 +0000 (+0000) Subject: mini-os: Fix memory leaks in xs_read() and xs_write() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12919 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=feb567f2108efa3108aeb500dcee2a978774e336;p=xen.git 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 --git a/extras/mini-os/lib/xs.c b/extras/mini-os/lib/xs.c index b654b0ee5d..6eced70347 100644 --- a/extras/mini-os/lib/xs.c +++ b/extras/mini-os/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;