Skip to contentSkip to conversation

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

PATCH In review Yu Zhiguo 2 participants 2 messages Dec 10, 2009

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

PATCH 1/1 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.

extras/mini-os/lib/xs.c +2 -0
@@ -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;