If buffers were allocated and then locked without ever
being passed to another process lock would return NULL
instead of a pointer to the buffer. Instead map the buffer
from lock if it hasn't already been done by register. Also
check in free and unmap the buffer it is mapped.
Change-Id: I3fe670ccb429f3de5f2e4dd07768414e70a02036
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle);
gralloc_module_t* module = reinterpret_cast<gralloc_module_t*>(
dev->common.module);
+ if (hnd->base)
+ grallocUnmap(module, const_cast<private_handle_t*>(hnd));
close(hnd->fd);
if (hnd->fd1 >= 0)
return -EINVAL;
private_handle_t* hnd = (private_handle_t*)handle;
+ if (!hnd->base)
+ gralloc_map(module, hnd);
*vaddr = (void*)hnd->base;
return 0;
}