dmabuf: fix mmap counting
authorMichael Olbrich <m.olbrich@pengutronix.de>
Fri, 23 Aug 2013 16:06:36 +0000 (18:06 +0200)
committerSebastian Dröge <slomo@circular-chaos.org>
Mon, 26 Aug 2013 07:29:32 +0000 (09:29 +0200)
A successful gst_dmabuf_mem_map must always increment the mmap count.
Otherwise the first gst_dmabuf_mem_unmap will unmap the memory and all
other user will access unmapped memory.

https://bugzilla.gnome.org/show_bug.cgi?id=706680

gst-libs/gst/allocators/gstdmabuf.c

index 1c8abc4..87d0c75 100644 (file)
@@ -90,8 +90,10 @@ gst_dmabuf_mem_map (GstMemory * gmem, gsize maxsize, GstMapFlags flags)
   if (mem->data) {
     /* only return address if mapping flags are a subset
      * of the previous flags */
-    if ((mem->mmapping_flags & prot) && (mem->mmap_size >= maxsize))
+    if ((mem->mmapping_flags & prot) && (mem->mmap_size >= maxsize)) {
       ret = mem->data;
+      mem->mmap_count++;
+    }
 
     goto out;
   }