summaryrefslogtreecommitdiff
path: root/cros_gralloc
diff options
context:
space:
mode:
authorGurchetan Singh <gurchetansingh@google.com>2017-05-26 10:04:29 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-05-31 02:15:28 -0700
commit989873c44c6dff1a28b10e4c0dfb13d3e3defaa9 (patch)
treee13dc431b4a0b48c4cc5515bdcdb749c07f5aed3 /cros_gralloc
parent8ac0c9a9550bd1fa57e49613fae45df9001f74fc (diff)
minigbm: cros_gralloc: fix incorrect handle calculations
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>
Diffstat (limited to 'cros_gralloc')
-rw-r--r--cros_gralloc/cros_alloc_device.cc2
-rw-r--r--cros_gralloc/cros_gralloc_helpers.h3
2 files changed, 3 insertions, 2 deletions
diff --git a/cros_gralloc/cros_alloc_device.cc b/cros_gralloc/cros_alloc_device.cc
index 2d7178a..5eda6b8 100644
--- a/cros_gralloc/cros_alloc_device.cc
+++ b/cros_gralloc/cros_alloc_device.cc
@@ -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);
diff --git a/cros_gralloc/cros_gralloc_helpers.h b/cros_gralloc/cros_gralloc_helpers.h
index 026d92a..457fcac 100644
--- a/cros_gralloc/cros_gralloc_helpers.h
+++ b/cros_gralloc/cros_gralloc_helpers.h
@@ -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;