fbmemory: need unmap if mapping flags are not subset of previous

upstream status: Pending
https://bugzilla.gnome.org/show_bug.cgi?id=789952
diff --git a/gst-libs/gst/allocators/gstfdmemory.c b/gst-libs/gst/allocators/gstfdmemory.c
index ad428a7..1e6125a 100644
--- a/gst-libs/gst/allocators/gstfdmemory.c
+++ b/gst-libs/gst/allocators/gstfdmemory.c
@@ -97,9 +97,13 @@
     if ((mem->mmapping_flags & prot) == prot) {
       ret = mem->data;
       mem->mmap_count++;
+      goto out;
+    } else {
+      /* if mapping flags is not a subset, need unmap first */
+      munmap ((void *) mem->data, gmem->maxsize);
+      mem->data = NULL;
+      mem->mmap_count = 0;;
     }
-
-    goto out;
   }
 
   if (mem->fd != -1) {