Tweaked order deallocations happen for an async buffer allocated
authorFrank Mori Hess <fmhess@speakeasy.net>
Wed, 2 May 2007 13:30:21 +0000 (13:30 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Wed, 2 May 2007 13:30:21 +0000 (13:30 +0000)
with vmalloc.

comedi/drivers.c

index e96cd2d36fc0cd875434717ae4bffa767a6097cd..49997aac155c68718a2b1b2093a8788e913dfc4a 100644 (file)
@@ -437,15 +437,10 @@ int comedi_buf_alloc(comedi_device *dev, comedi_subdevice *s,
        if(async->prealloc_buf && async->prealloc_bufsz == new_size){
                return 0;
        }
-       if(async->prealloc_buf)
+       // deallocate old buffer
+       if(async->prealloc_buf && s->async_dma_dir != DMA_NONE)
        {
-               if(s->async_dma_dir != DMA_NONE)
-               {
-                       vunmap(async->prealloc_buf);
-               }else
-               {
-                       vfree(async->prealloc_buf);
-               }
+               vunmap(async->prealloc_buf);
                async->prealloc_buf = NULL;
                async->prealloc_bufsz = 0;
        }
@@ -466,6 +461,12 @@ int comedi_buf_alloc(comedi_device *dev, comedi_subdevice *s,
                async->buf_page_list = NULL;
                async->n_buf_pages = 0;
        }
+       if(async->prealloc_buf && s->async_dma_dir == DMA_NONE)
+       {
+               vfree(async->prealloc_buf);
+               async->prealloc_buf = NULL;
+               async->prealloc_bufsz = 0;
+       }
        // allocate new buffer
        if(new_size){
                int i;