[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [PATCH] Save/Restore Support: Fix defects introduced to MiniOS.



Fix memory leaks and memory management bugs introduced to MiniOS by
lastest commits.

Signed-off-by: Bruno Alvisio <bruno.alvisio@xxxxxxxxx>
---
 netfront.c      | 16 +++++++++-------
 xenbus/xenbus.c |  5 ++++-
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/netfront.c b/netfront.c
index 50b3a57..ad40076 100644
--- a/netfront.c
+++ b/netfront.c
@@ -321,6 +321,7 @@ struct netfront_dev *init_netfront(char *_nodename,
         if (strcmp(nodename, list->dev->nodename) == 0) {
             list->refcount++;
             dev = list->dev;
+            ldev = list;
             if (thenetif_rx)
                 netfront_set_rx_handler(dev, thenetif_rx, NULL);
             goto out;
@@ -384,7 +385,7 @@ static struct netfront_dev *_init_netfront(struct 
netfront_dev *dev,
                                           char **ip)
 {
     xenbus_transaction_t xbt;
-    char* err = NULL;
+    char* err = NULL, *err2;
     char* message=NULL;
     struct netif_tx_sring *txs;
     struct netif_rx_sring *rxs;
@@ -474,8 +475,8 @@ again:
     err = xenbus_transaction_end(xbt, 0, &retry);
     free(err);
     if (retry) {
+        printk("retrying transaction\n");
         goto again;
-        printk("completing transaction\n");
     }
 
     goto done;
@@ -489,8 +490,10 @@ abort_transaction:
 done:
     snprintf(path, sizeof(path), "%s/backend", dev->nodename);
     msg = xenbus_read(XBT_NIL, path, &dev->backend);
+    free(msg);
     snprintf(path, sizeof(path), "%s/mac", dev->nodename);
     msg = xenbus_read(XBT_NIL, path, &dev->mac);
+    free(msg);
 
     if ((dev->backend == NULL) || (dev->mac == NULL)) {
         printk("%s: backend/mac failed\n", __func__);
@@ -513,13 +516,15 @@ done:
             err = xenbus_wait_for_state_change(path, &state, &dev->events);
         if (state != XenbusStateConnected) {
             printk("backend not avalable, state=%d\n", state);
-            xenbus_unwatch_path_token(XBT_NIL, path, path);
+            err2 = xenbus_unwatch_path_token(XBT_NIL, path, path);
+            free(err2);
             goto error;
         }
 
         if (ip) {
             snprintf(path, sizeof(path), "%s/ip", dev->backend);
-            xenbus_read(XBT_NIL, path, ip);
+            msg = xenbus_read(XBT_NIL, path, ip);
+            free(msg);
         }
     }
 
@@ -542,7 +547,6 @@ done:
     return dev;
 
 error:
-    free(msg);
     free(err);
     free_netfront(dev);
     return NULL;
@@ -584,8 +588,6 @@ void shutdown_netfront(struct netfront_dev *dev)
     list->refcount--;
     if (list->refcount == 0) {
         _shutdown_netfront(dev);
-        free(dev->nodename);
-        free(dev);
 
         to_del = list;
         if (to_del == dev_list) {
diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
index d72dc3a..695c24d 100644
--- a/xenbus/xenbus.c
+++ b/xenbus/xenbus.c
@@ -413,8 +413,11 @@ void resume_xenbus(int canceled)
 
             rep = xenbus_msg_reply(XS_WATCH, XBT_NIL, req, ARRAY_SIZE(req));
             msg = errmsg(rep);
-            if (msg)
+            if (msg) {
                 xprintk("error on XS_WATCH: %s\n", msg);
+                free(msg);
+                return;
+            }
             free(rep);
         }
     }
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.