]> xenbits.xensource.com Git - people/liuw/mini-os.git/commitdiff
minios: fix gnttab allocation boundary
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 18 Jun 2008 08:38:11 +0000 (09:38 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 18 Jun 2008 08:38:11 +0000 (09:38 +0100)
The gnttab_sem is already fed during initialization's put_free_entry
loop.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
gnttab.c

index d94c28b815fb4c346d73af7cb988b3a3b321197c..18fd87e29cb2adadde71c893232a8f4476decc30 100644 (file)
--- a/gnttab.c
+++ b/gnttab.c
@@ -35,7 +35,7 @@ static grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
 #ifdef GNT_DEBUG
 static char inuse[NR_GRANT_ENTRIES];
 #endif
-static __DECLARE_SEMAPHORE_GENERIC(gnttab_sem, NR_GRANT_ENTRIES);
+static __DECLARE_SEMAPHORE_GENERIC(gnttab_sem, 0);
 
 static void
 put_free_entry(grant_ref_t ref)
@@ -60,6 +60,7 @@ get_free_entry(void)
     down(&gnttab_sem);
     local_irq_save(flags);
     ref = gnttab_list[0];
+    BUG_ON(ref < NR_RESERVED_ENTRIES || ref >= NR_GRANT_ENTRIES);
     gnttab_list[0] = gnttab_list[ref];
 #ifdef GNT_DEBUG
     BUG_ON(inuse[ref]);