From e09a5d04dbb41ff646096b2f1913618cefd651e7 Mon Sep 17 00:00:00 2001 From: Prabhanjan Kandula Date: Thu, 30 Aug 2012 11:30:23 +0530 Subject: [PATCH] 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 --- libgralloc/ionalloc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libgralloc/ionalloc.cpp b/libgralloc/ionalloc.cpp index 8af5a96..e01e3df 100644 --- a/libgralloc/ionalloc.cpp +++ b/libgralloc/ionalloc.cpp @@ -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; }