Don't unlock Android buffers immediately after locking them.

In some Android gralloc implementations (e.g. minigbm), the lock operation
corresponds to mmap, and unlock corresponds to munmap. This means that
this code was previously returning an unusable buffer in the case where
lockInternal is called passing LOCK_UNLOCKED (e.g. the mipmap buffer
initializer in Sampler.cpp), resulting in segfaults later on.

To prevent this from happening, don't unlock the native buffer and just leak
the reference.

Bug: b/142352330
Change-Id: I553801f32978c1d0af4597baad374381585e78ad
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/44168
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Presubmit-Ready: Peter Collingbourne <pcc@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/common/Image.hpp b/src/OpenGL/common/Image.hpp
index 4dc53f4..dec2ad0 100644
--- a/src/OpenGL/common/Image.hpp
+++ b/src/OpenGL/common/Image.hpp
@@ -303,13 +303,6 @@
 
 			// Lock the ANativeWindowBuffer and use its address.
 			data = lockNativeBuffer(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
-
-			if(lock == sw::LOCK_UNLOCKED)
-			{
-				// We're never going to get a corresponding unlock, so unlock
-				// immediately. This keeps the gralloc reference counts sane.
-				unlockNativeBuffer();
-			}
 		}
 
 		return data;