Skip to contentSkip to conversation

minios: Fix blkfront grant map leak

PATCH New Samuel Thibault 1 participant 1 message Feb 6, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 minios: Fix blkfront grant map leak

minios: Fix blkfront grant map leak

extras/mini-os/blkfront.c +3 -3
diff -r 96a97839ecb7 extras/mini-os/blkfront.c
@@ -272,7 +272,7 @@ void blkfront_aio(struct blkfront_aiocb 
 
     start = (uintptr_t)aiocbp->aio_buf & PAGE_MASK;
     end = ((uintptr_t)aiocbp->aio_buf + aiocbp->aio_nbytes + PAGE_SIZE - 1) & PAGE_MASK;
-    n = (end - start) / PAGE_SIZE;
+    aiocbp->n = n = (end - start) / PAGE_SIZE;
 
     /* qemu's IDE max multsect is 16 (8KB) and SCSI max DMA was set to 32KB,
      * so max 44KB can't happen */
@@ -341,8 +341,8 @@ moretodo:
         case BLKIF_OP_WRITE:
         {
             struct blkfront_aiocb *aiocbp = (void*) (uintptr_t) rsp->id;
-            int n = (aiocbp->aio_nbytes + PAGE_SIZE - 1) / PAGE_SIZE, j;
-            for (j = 0; j < n; j++)
+            int j;
+            for (j = 0; j < aiocbp->n; j++)
                 gnttab_end_access(aiocbp->gref[j]);
 
             /* Nota: callback frees aiocbp itself */
extras/mini-os/include/blkfront.h +1 -0
diff -r 96a97839ecb7 extras/mini-os/include/blkfront.h
@@ -11,6 +11,7 @@ struct blkfront_aiocb
     void *data;
 
     grant_ref_t gref[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+    int n;
 
     void (*aio_cb)(struct blkfront_aiocb *aiocb, int ret);
 };