From: HeYue Date: Tue, 6 Nov 2018 06:58:38 +0000 (+0800) Subject: Fix the ACRN Invalid Reference error in buffer release. X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-minigbm.git;a=commitdiff_plain;h=98856eaa3b24af392cae08d5760702707dff4b90 Fix the ACRN Invalid Reference error in buffer release. Use multi method to allocate the release buffer Jira: https://jira01.devtools.intel.com/browse/OAM-71272 Tests: Do not have invalid reference error and DUT without other issue. Signed-off-by: HeYue --- diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc index f78c7e0..a0e312a 100644 --- a/cros_gralloc/cros_gralloc_driver.cc +++ b/cros_gralloc/cros_gralloc_driver.cc @@ -240,11 +240,21 @@ int32_t cros_gralloc_driver::release(buffer_handle_t handle) auto buffer = get_buffer(hnd); if (!buffer) { - cros_gralloc_error("Invalid Reference."); - return -EINVAL; + uint32_t id = -1; + if (drmPrimeFDToHandle(drv_get_fd(drv_), hnd->fds[0], &id)) { + cros_gralloc_error("drmPrimeFDToHandle failed."); + return -errno; + } + if (buffers_.count(id)) { + buffer = buffers_[id]; + buffer->increase_refcount(); + } + else { + cros_gralloc_error("Could not found reference"); + return -EINVAL; + } } - - if (!--handles_[hnd].second) + else if (!--handles_[hnd].second) handles_.erase(hnd); if (buffer->decrease_refcount() == 0) {