libgralloc: Fix possible leak of fd

Fix possible leak of fd in ion allocation.
If mmap fails close the fd before returning.

Change-Id: Id414792c14a75259f6075b0d76bc470c31fb5853
CRs-fixed: 387633
This commit is contained in:
Prabhanjan Kandula 2012-08-30 11:30:23 +05:30 committed by Andrew Sutherland
parent 36445e454b
commit e09a5d04db

View File

@ -126,6 +126,8 @@ int IonAlloc::alloc_buffer(alloc_data& data)
ALOGE("%s: Failed to map the allocated memory: %s",
__FUNCTION__, strerror(errno));
ioctl(mIonFd, ION_IOC_FREE, &handle_data);
if(ionSyncFd >= 0)
close(ionSyncFd);
ionSyncFd = FD_INIT;
return err;
}