From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu Zhiguo Subject: [PATCH] mini-os: Fix memory leaks in xs_read() and xs_write() Date: Thu, 10 Dec 2009 15:36:41 +0800 Message-ID: <4B20A509.8030706@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org 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 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;