WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] minios: free blkfront resources on error/

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] minios: free blkfront resources on error/shutdown
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 May 2008 09:40:20 -0700
Delivery-date: Mon, 12 May 2008 09:41:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1210586481 -3600
# Node ID c6533d246a8145e342de71cc7b6dc80b8995c68e
# Parent  9f8b8315339ee6b512ae2f98b61bdf51be368783
minios: free blkfront resources on error/shutdown

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
---
 extras/mini-os/blkfront.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff -r 9f8b8315339e -r c6533d246a81 extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Mon May 12 10:36:27 2008 +0100
+++ b/extras/mini-os/blkfront.c Mon May 12 11:01:21 2008 +0100
@@ -68,6 +68,21 @@ void blkfront_handler(evtchn_port_t port
     wake_up(&blkfront_queue);
 }
 
+static void free_blkfront(struct blkfront_dev *dev)
+{
+    mask_evtchn(dev->evtchn);
+
+    free(dev->backend);
+
+    gnttab_end_access(dev->ring_ref);
+    free_page(dev->ring.sring);
+
+    unbind_evtchn(dev->evtchn);
+
+    free(dev->nodename);
+    free(dev);
+}
+
 struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info)
 {
     xenbus_transaction_t xbt;
@@ -88,6 +103,7 @@ struct blkfront_dev *init_blkfront(char 
     printk("******************* BLKFRONT for %s **********\n\n\n", nodename);
 
     dev = malloc(sizeof(*dev));
+    memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
@@ -139,7 +155,7 @@ again:
 
 abort_transaction:
     xenbus_transaction_end(xbt, 1, &retry);
-    return NULL;
+    goto error;
 
 done:
 
@@ -147,7 +163,7 @@ done:
     msg = xenbus_read(XBT_NIL, path, &dev->backend);
     if (msg) {
         printk("Error %s when reading the backend path %s\n", msg, path);
-        return NULL;
+        goto error;
     }
 
     printk("backend at %s\n", dev->backend);
@@ -160,7 +176,7 @@ done:
         msg = xenbus_read(XBT_NIL, path, &c);
         if (msg) {
             printk("Error %s when reading the mode\n", msg);
-            return NULL;
+            goto error;
         }
         if (*c == 'w')
             dev->info.mode = O_RDWR;
@@ -198,6 +214,10 @@ done:
     printk("**************************\n");
 
     return dev;
+
+error:
+    free_blkfront(dev);
+    return NULL;
 }
 
 void shutdown_blkfront(struct blkfront_dev *dev)
@@ -220,11 +240,7 @@ void shutdown_blkfront(struct blkfront_d
 
     xenbus_unwatch_path(XBT_NIL, path);
 
-    unbind_evtchn(dev->evtchn);
-
-    free(nodename);
-    free(dev->backend);
-    free(dev);
+    free_blkfront(dev);
 }
 
 static void blkfront_wait_slot(struct blkfront_dev *dev)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] minios: free blkfront resources on error/shutdown, Xen patchbot-unstable <=