dmabuf: Make sure that memory is unmapped before releasing it

Be sure that memory is unmapped before releasing it.

https://bugzilla.gnome.org/show_bug.cgi?id=700411
This commit is contained in:
Benjamin Gaignard 2013-05-17 09:16:08 +02:00 committed by Sebastian Dröge
parent 612e20d4f6
commit e90e2bb822

View file

@ -62,17 +62,18 @@ GST_DEBUG_CATEGORY_STATIC (dmabuf_debug);
#define GST_CAT_DEFAULT dmabuf_debug #define GST_CAT_DEFAULT dmabuf_debug
static void static void
gst_dmabuf_allocator_free (GstAllocator * allocator, GstMemory * mem) gst_dmabuf_allocator_free (GstAllocator * allocator, GstMemory * gmem)
{ {
GstDmaBufMemory *dbmem = (GstDmaBufMemory *) mem; GstDmaBufMemory *mem = (GstDmaBufMemory *) gmem;
if (dbmem->data) if (mem->data) {
g_warning ("Freeing memory still mapped"); g_warning (G_STRLOC ":%s: Freeing memory %p still mapped", G_STRFUNC, mem);
munmap ((void *) mem->data, mem->mmap_size);
close (dbmem->fd); }
g_mutex_clear (&dbmem->lock); close (mem->fd);
g_slice_free (GstDmaBufMemory, dbmem); g_mutex_clear (&mem->lock);
GST_DEBUG ("%p: freed", dbmem); g_slice_free (GstDmaBufMemory, mem);
GST_DEBUG ("%p: freed", mem);
} }
static gpointer static gpointer