Close Fence FDs in error cases of Surface and GraphicBufferMapper

Surface::{cancel,queue}Buffer and GraphicBufferMapper::lockAsyncYCbCr take the
ownership of |fenceFd|s. Though they don't close it on error cases.

Change-Id: I49a7ce8837d5c510c4ac4ad4649f310d18610e80
This commit is contained in:
Taiju Tsuiki 2015-04-30 22:15:33 +09:00
parent de5c15b8bd
commit c7263fb432
2 changed files with 9 additions and 0 deletions

View File

@ -267,6 +267,9 @@ int Surface::cancelBuffer(android_native_buffer_t* buffer,
Mutex::Autolock lock(mMutex);
int i = getSlotFromBufferLocked(buffer);
if (i < 0) {
if (fenceFd >= 0) {
close(fenceFd);
}
return i;
}
sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
@ -308,6 +311,9 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
}
int i = getSlotFromBufferLocked(buffer);
if (i < 0) {
if (fenceFd >= 0) {
close(fenceFd);
}
return i;
}

View File

@ -160,6 +160,9 @@ status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
bounds.left, bounds.top, bounds.width(), bounds.height(),
ycbcr);
} else {
if (fenceFd >= 0) {
close(fenceFd);
}
return -EINVAL; // do not log failure
}