Skip to contentSkip to conversation

minios: fix gnttab allocation boundary

PATCH New Samuel Thibault 1 participant 1 message Jun 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 minios: fix gnttab allocation boundary

minios: fix gnttab allocation boundary

The gnttab_sem is already fed during initialization's put_free_entry loop.

extras/mini-os/gnttab.c +2 -1
diff -r 78f90b0f707f extras/mini-os/gnttab.c
@@ -35,7 +35,7 @@
 #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 @@
     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]);