]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
minios: Fix blkfront grant map leak
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 7 Feb 2008 09:16:20 +0000 (09:16 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 7 Feb 2008 09:16:20 +0000 (09:16 +0000)
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
blkfront.c
include/blkfront.h

index f07900580b5689ee6cf2234dad3f589149aa412c..881efd3055662c527d5e0cb7451b7c5fc82dca24 100644 (file)
@@ -258,7 +258,7 @@ void blkfront_aio(struct blkfront_aiocb *aiocbp, int write)
 
     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 */
@@ -327,8 +327,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 */
index 92e658e899f1bc0a1e5f38c9ee3ae8b79764cb22..034c793ff679278013223775e2696b8f6f682fc2 100644 (file)
@@ -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);
 };