gralloc1: Do not do early validation on Release
Check if handle exists in map first. CRs-Fixed: 2074655 Change-Id: Ia928f1f09578b9ab21479ce237a56555f29ca9c5
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
9f82642b7b
commit
a186b47650
@@ -192,7 +192,13 @@ void BufferManager::CreateSharedHandle(buffer_handle_t inbuffer, const BufferDes
|
||||
|
||||
gralloc1_error_t BufferManager::FreeBuffer(std::shared_ptr<Buffer> buf) {
|
||||
auto hnd = buf->handle;
|
||||
ALOGD_IF(DEBUG, "FreeBuffer handle:%p id: %" PRIu64, hnd, hnd->id);
|
||||
ALOGD_IF(DEBUG, "FreeBuffer handle:%p", hnd);
|
||||
|
||||
if (private_handle_t::validate(hnd) != 0) {
|
||||
ALOGE("FreeBuffer: Invalid handle: %p", hnd);
|
||||
return GRALLOC1_ERROR_BAD_HANDLE;
|
||||
}
|
||||
|
||||
if (allocator_->FreeBuffer(reinterpret_cast<void *>(hnd->base), hnd->size, hnd->offset,
|
||||
hnd->fd, buf->ion_handle_main) != 0) {
|
||||
return GRALLOC1_ERROR_BAD_HANDLE;
|
||||
@@ -284,7 +290,7 @@ gralloc1_error_t BufferManager::RetainBuffer(private_handle_t const *hnd) {
|
||||
}
|
||||
|
||||
gralloc1_error_t BufferManager::ReleaseBuffer(private_handle_t const *hnd) {
|
||||
ALOGD_IF(DEBUG, "Release buffer handle:%p id: %" PRIu64, hnd, hnd->id);
|
||||
ALOGD_IF(DEBUG, "Release buffer handle:%p", hnd);
|
||||
std::lock_guard<std::mutex> lock(buffer_lock_);
|
||||
auto buf = GetBufferFromHandleLocked(hnd);
|
||||
if (buf == nullptr) {
|
||||
|
||||
@@ -392,14 +392,13 @@ gralloc1_error_t GrallocImpl::RetainBuffer(gralloc1_device_t *device, buffer_han
|
||||
}
|
||||
|
||||
gralloc1_error_t GrallocImpl::ReleaseBuffer(gralloc1_device_t *device, buffer_handle_t buffer) {
|
||||
gralloc1_error_t status = CheckDeviceAndHandle(device, buffer);
|
||||
if (status == GRALLOC1_ERROR_NONE) {
|
||||
const private_handle_t *hnd = PRIV_HANDLE_CONST(buffer);
|
||||
GrallocImpl const *dev = GRALLOC_IMPL(device);
|
||||
status = dev->buf_mgr_->ReleaseBuffer(hnd);
|
||||
if (!device || !buffer) {
|
||||
return GRALLOC1_ERROR_BAD_DESCRIPTOR;
|
||||
}
|
||||
|
||||
return status;
|
||||
const private_handle_t *hnd = PRIV_HANDLE_CONST(buffer);
|
||||
GrallocImpl const *dev = GRALLOC_IMPL(device);
|
||||
return dev->buf_mgr_->ReleaseBuffer(hnd);
|
||||
}
|
||||
|
||||
gralloc1_error_t GrallocImpl::GetNumFlexPlanes(gralloc1_device_t *device, buffer_handle_t buffer,
|
||||
|
||||
Reference in New Issue
Block a user