minigbm: cros_gralloc/buffer: Do not read from output array

Even though it does not currently imply any technical issues, it is not
very elegant for the code to assign buffer map base to addr[0] first and
then modify it in a loop by adding a plan address. Let's just store the
map base in a local variable and use it in plane address calculation.

BUG=b:38250067
TEST=android.media.cts.DecoderTest on veyron_minnie

Change-Id: If2e95086385d96ced760cc94c8c747bffd0c6f55
Reviewed-on: https://chromium-review.googlesource.com/592988
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
diff --git a/cros_gralloc/cros_gralloc_buffer.cc b/cros_gralloc/cros_gralloc_buffer.cc
index 668fa41..b6da605 100644
--- a/cros_gralloc/cros_gralloc_buffer.cc
+++ b/cros_gralloc/cros_gralloc_buffer.cc
@@ -46,6 +46,8 @@
 
 int32_t cros_gralloc_buffer::lock(uint64_t flags, uint8_t *addr[DRV_MAX_PLANES])
 {
+	void *vaddr = nullptr;
+
 	memset(addr, 0, DRV_MAX_PLANES * sizeof(*addr));
 
 	/*
@@ -58,7 +60,6 @@
 	}
 
 	if (flags) {
-		void *vaddr;
 		if (lock_data_[0]) {
 			vaddr = lock_data_[0]->addr;
 		} else {
@@ -70,12 +71,10 @@
 			cros_gralloc_error("Mapping failed.");
 			return -EFAULT;
 		}
-
-		addr[0] = static_cast<uint8_t *>(vaddr);
 	}
 
 	for (uint32_t plane = 0; plane < num_planes_; plane++)
-		addr[plane] = addr[0] + drv_bo_get_plane_offset(bo_, plane);
+		addr[plane] = static_cast<uint8_t *>(vaddr) + drv_bo_get_plane_offset(bo_, plane);
 
 	lockcount_++;
 	return 0;