Increment the DMA counter if gralloc_alloc completes successfully
There was "delete cb" without decrementing the DMA counter which
could lead to a leak.
Bug: 128324105
Test: make
Change-Id: I7307c133a84132e76648fbfe1e60e49a5ef477dc
Signed-off-by: Roman Kiryanov <rkir@google.com>
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index ff2c744..57a9e9e 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -709,15 +709,6 @@
}
cb->setFd(fd);
-
- hostCon->lock();
-
- if (rcEnc->getDmaVersion() > 0) {
- D("%s: creating goldfish dma region of size %lu (cb fd %d)\n", __FUNCTION__, ashmem_size, cb->fd);
- init_gralloc_dmaregion();
- get_gralloc_dmaregion();
- }
- hostCon->unlock();
}
if (needHostCb) {
@@ -776,6 +767,14 @@
*pStride = stride;
break;
}
+
+ hostCon->lock();
+ if (rcEnc->getDmaVersion() > 0) {
+ init_gralloc_dmaregion();
+ get_gralloc_dmaregion();
+ }
+ hostCon->unlock();
+
return 0;
}