[dev][usb-function] Fix test case where device is released.

If we close the cachecontrol_ device handle during the disconnect
in the ums-test, this will trigger the release function of the
ums-function device.

In ums-function bind, it looks like the writeback_cache_ check
will never be true, since we just set it to false at the start of bind.
This means we are always using the static vmo for ums->storage.

In ums-function release, we check for whether writeback_cache_ is true,
to figure out if we should release the child vmo. However, this is
actually releasing the static vmo, as we never made the copy in bind.

Next time ums-function binds again, vmar_map will fail since the static
vmo has been released.

TEST= runtests -t usb-virtual-bus-ums-test
Updated test fails before ums-function changes, passes with changes.

Change-Id: I32939cface3887c9c897a608331e1823b502db9d
diff --git a/zircon/system/dev/block/ums-function/ums-function.c b/zircon/system/dev/block/ums-function/ums-function.c
index f0d9c36..afe3ecc 100644
--- a/zircon/system/dev/block/ums-function/ums-function.c
+++ b/zircon/system/dev/block/ums-function/ums-function.c
@@ -1,3 +1,4 @@
+
 // Copyright 2017 The Fuchsia Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
@@ -560,10 +561,6 @@
   if (ums->storage) {
     zx_vmar_unmap(zx_vmar_root_self(), (uintptr_t)ums->storage, STORAGE_SIZE);
   }
-  if (ums->writeback_cache) {
-    zx_handle_close(ums->storage_handle);
-  }
-
   if (ums->cbw_req) {
     usb_request_release(ums->cbw_req);
   }
@@ -705,23 +702,11 @@
   // create and map a VMO
   if (!vmo) {
     status = zx_vmo_create(STORAGE_SIZE, 0, &vmo);
-  }
-  if (ums->writeback_cache) {
-    uint64_t size;
-    status = zx_vmo_get_size(vmo, &size);
     if (status != ZX_OK) {
       goto fail;
     }
-    status = zx_vmo_create_child(vmo, ZX_VMO_CHILD_COPY_ON_WRITE, 0, size, &ums->storage_handle);
-    if (status != ZX_OK) {
-      goto fail;
-    }
-  } else {
-    ums->storage_handle = vmo;
   }
-  if (status != ZX_OK) {
-    goto fail;
-  }
+  ums->storage_handle = vmo;
   status = zx_vmar_map(zx_vmar_root_self(), ZX_VM_PERM_READ | ZX_VM_PERM_WRITE, 0,
                        ums->storage_handle, 0, STORAGE_SIZE, (zx_vaddr_t*)&ums->storage);
   if (status != ZX_OK) {
diff --git a/zircon/system/utest/usb-virtual-bus/ums-test.cc b/zircon/system/utest/usb-virtual-bus/ums-test.cc
index 8409003..dd1024c 100644
--- a/zircon/system/utest/usb-virtual-bus/ums-test.cc
+++ b/zircon/system/utest/usb-virtual-bus/ums-test.cc
@@ -92,6 +92,7 @@
   explicit BlockDeviceController(USBVirtualBus* bus) : bus_(bus) {}
 
   void Disconnect() {
+    cachecontrol_.reset();
     auto result = peripheral().ClearFunctions();
     ASSERT_OK(result.status());
     ASSERT_FALSE(result->result.is_err());