dmabuf: handle mmap failure
authorMichael Olbrich <m.olbrich@pengutronix.de>
Thu, 2 May 2013 13:37:14 +0000 (15:37 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 3 May 2013 09:05:55 +0000 (11:05 +0200)
Otherwise gstreamer may segfault trying to access MAP_FAILED.

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

gst-libs/gst/allocators/gstdmabuf.c

index 5cca888..12540bc 100644 (file)
@@ -96,8 +96,15 @@ gst_dmabuf_mem_map (GstMemory * gmem, gsize maxsize, GstMapFlags flags)
     goto out;
   }
 
-  if (mem->fd != -1)
+  if (mem->fd != -1) {
     mem->data = mmap (0, maxsize, prot, MAP_SHARED, mem->fd, 0);
+    if (mem->data == MAP_FAILED) {
+      mem->data = NULL;
+      GST_ERROR ("%p: fd %d: mmap failed: %s", mem, mem->fd,
+          g_strerror(errno));
+      goto out;
+    }
+  }
 
   GST_DEBUG ("%p: fd %d: mapped %p", mem, mem->fd, mem->data);