OSDN Git Service

minigbm: cros_gralloc: fix incorrect handle calculations
authorGurchetan Singh <gurchetansingh@google.com>
Fri, 26 May 2017 17:04:29 +0000 (10:04 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Wed, 31 May 2017 09:15:28 +0000 (02:15 -0700)
We were including native handle size in our numInts calculations.
Fix this.

BUG=b:62060380
TEST=gralloc related ASAN errors go away

Change-Id: I9ae66655f9e40d82a9cd3fe91ddca9f300fda911
Reviewed-on: https://chromium-review.googlesource.com/517279
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Luis Hector Chavez <lhchavez@chromium.org>
cros_gralloc/cros_alloc_device.cc
cros_gralloc/cros_gralloc_helpers.h

index 2d7178a..5eda6b8 100644 (file)
@@ -71,7 +71,7 @@ static struct cros_gralloc_handle *cros_gralloc_handle_from_bo(struct bo *bo)
 
        hnd->base.version = sizeof(hnd->base);
        hnd->base.numFds = num_planes;
-       hnd->base.numInts = num_ints_handle - num_planes;
+       hnd->base.numInts = handle_data_size - num_planes;
 
        for (size_t p = 0; p < num_planes; p++) {
                hnd->fds[p] = drv_bo_get_plane_fd(bo, p);
index 026d92a..457fcac 100644 (file)
@@ -44,7 +44,8 @@ enum {
 
 constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA;
 
-constexpr uint32_t num_ints_handle = ((sizeof(struct cros_gralloc_handle)) / sizeof(int));
+constexpr uint32_t handle_data_size =
+    ((sizeof(struct cros_gralloc_handle) - offsetof(cros_gralloc_handle, fds[0])) / sizeof(int));
 
 constexpr uint32_t sw_access = GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK;