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-devel

Re: [Xen-devel] [PATCH] minios: free fbfront resources on error/shutdown

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] minios: free fbfront resources on error/shutdown
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Mon, 12 May 2008 14:16:11 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 12 May 2008 05:16:59 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C44DD7DB.20836%keir.fraser@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
References: <20080512101146.GD5753@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> <C44DD7DB.20836%keir.fraser@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
Keir Fraser, le Mon 12 May 2008 11:17:47 +0100, a écrit :
> Doesn't apply to xen-unstable tip c/s 17616.

Here is a fixed patch


minios: free fbfront resources on error/shutdown

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r 2d8d5b7ada6f extras/mini-os/fbfront.c
--- a/extras/mini-os/fbfront.c  Mon May 12 14:14:45 2008 +0200
+++ b/extras/mini-os/fbfront.c  Mon May 12 14:15:31 2008 +0200
@@ -47,6 +47,20 @@
     files[fd].read = 1;
 #endif
     wake_up(&kbdfront_queue);
+}
+
+static void free_kbdfront(struct kbdfront_dev *dev)
+{
+    mask_evtchn(dev->evtchn);
+
+    free(dev->backend);
+
+    free_page(dev->page);
+
+    unbind_evtchn(dev->evtchn);
+
+    free(dev->nodename);
+    free(dev);
 }
 
 struct kbdfront_dev *init_kbdfront(char *nodename, int abs_pointer)
@@ -122,7 +136,7 @@
 
 abort_transaction:
     xenbus_transaction_end(xbt, 1, &retry);
-    return NULL;
+    goto error;
 
 done:
 
@@ -130,7 +144,7 @@
     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);
@@ -153,6 +167,9 @@
     printk("************************** KBDFRONT\n");
 
     return dev;
+error:
+    free_kbdfront(dev);
+    return NULL;
 }
 
 int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int 
n)
@@ -208,12 +225,7 @@
 
     xenbus_unwatch_path(XBT_NIL, path);
 
-    unbind_evtchn(dev->evtchn);
-
-    free_page(dev->page);
-    free(nodename);
-    free(dev->backend);
-    free(dev);
+    free_kbdfront(dev);
 }
 
 #ifdef HAVE_LIBC
@@ -270,6 +282,20 @@
     files[fd].read = 1;
 #endif
     wake_up(&fbfront_queue);
+}
+
+static void free_fbfront(struct fbfront_dev *dev)
+{
+    mask_evtchn(dev->evtchn);
+
+    free(dev->backend);
+
+    free_page(dev->page);
+
+    unbind_evtchn(dev->evtchn);
+
+    free(dev->nodename);
+    free(dev);
 }
 
 int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
@@ -401,7 +427,7 @@
 
 abort_transaction:
     xenbus_transaction_end(xbt, 1, &retry);
-    return NULL;
+    goto error;
 
 done:
 
@@ -409,7 +435,7 @@
     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);
@@ -435,6 +461,10 @@
     printk("************************** FBFRONT\n");
 
     return dev;
+
+error:
+    free_fbfront(dev);
+    return NULL;
 }
 
 static void fbfront_out_event(struct fbfront_dev *dev, union xenfb_out_event 
*event)
@@ -521,10 +551,7 @@
 
     unbind_evtchn(dev->evtchn);
 
-    free_page(dev->page);
-    free(nodename);
-    free(dev->backend);
-    free(dev);
+    free_fbfront(dev);
 }
 
 #ifdef HAVE_LIBC


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

<Prev in Thread] Current Thread [Next in Thread>