|
@@ -763,7 +763,6 @@ static int cam_mem_util_buffer_alloc(size_t len, uint32_t flags,
|
|
unsigned long *i_ino)
|
|
unsigned long *i_ino)
|
|
{
|
|
{
|
|
int rc;
|
|
int rc;
|
|
- struct dma_buf *temp_dmabuf = NULL;
|
|
|
|
|
|
|
|
rc = cam_mem_util_get_dma_buf(len, flags, dmabuf, i_ino);
|
|
rc = cam_mem_util_get_dma_buf(len, flags, dmabuf, i_ino);
|
|
if (rc) {
|
|
if (rc) {
|
|
@@ -773,6 +772,13 @@ static int cam_mem_util_buffer_alloc(size_t len, uint32_t flags,
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * increment the ref count so that ref count becomes 2 here
|
|
|
|
+ * when we close fd, refcount becomes 1 and when we do
|
|
|
|
+ * dmap_put_buf, ref count becomes 0 and memory will be freed.
|
|
|
|
+ */
|
|
|
|
+ get_dma_buf(*dmabuf);
|
|
|
|
+
|
|
*fd = dma_buf_fd(*dmabuf, O_CLOEXEC);
|
|
*fd = dma_buf_fd(*dmabuf, O_CLOEXEC);
|
|
if (*fd < 0) {
|
|
if (*fd < 0) {
|
|
CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd);
|
|
CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd);
|
|
@@ -783,18 +789,6 @@ static int cam_mem_util_buffer_alloc(size_t len, uint32_t flags,
|
|
CAM_DBG(CAM_MEM, "Alloc success : len=%zu, *dmabuf=%pK, fd=%d, i_ino=%lu",
|
|
CAM_DBG(CAM_MEM, "Alloc success : len=%zu, *dmabuf=%pK, fd=%d, i_ino=%lu",
|
|
len, *dmabuf, *fd, *i_ino);
|
|
len, *dmabuf, *fd, *i_ino);
|
|
|
|
|
|
- /*
|
|
|
|
- * increment the ref count so that ref count becomes 2 here
|
|
|
|
- * when we close fd, refcount becomes 1 and when we do
|
|
|
|
- * dmap_put_buf, ref count becomes 0 and memory will be freed.
|
|
|
|
- */
|
|
|
|
- temp_dmabuf = dma_buf_get(*fd);
|
|
|
|
- if (IS_ERR_OR_NULL(temp_dmabuf)) {
|
|
|
|
- rc = PTR_ERR(temp_dmabuf);
|
|
|
|
- CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d, i_ino=%lu, rc=%d", *fd, *i_ino, rc);
|
|
|
|
- goto put_buf;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return rc;
|
|
return rc;
|
|
|
|
|
|
put_buf:
|
|
put_buf:
|