[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] minios: free blkfront resources on error/shutdown
# 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |