video: tegra: host: Fix memory leak in dmabuf
Arto Merilainen [Thu, 22 Nov 2012 09:35:16 +0000 (11:35 +0200)]
nvhost was not detached from imported dmabuf buffers correctly.
Refcount to the buffer was decreased so the actual memory area
was released. However, small amount of bookkeeping data was not
freed.

Change-Id: Ia2af6485a471cc77dcbb5235e2d525bbb5916a38
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/165660
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>

drivers/video/tegra/host/dmabuf.c

index 9ec13b2..19b5e6d 100644 (file)
@@ -45,7 +45,10 @@ struct mem_handle *nvhost_dmabuf_alloc(size_t size, size_t align, int flags)
 
 void nvhost_dmabuf_put(struct mem_handle *handle)
 {
-       dma_buf_put(to_dmabuf(handle));
+       struct dma_buf_attachment *attach = to_dmabuf_att(handle);
+       struct dma_buf *dmabuf = attach->dmabuf;
+       dma_buf_detach(dmabuf, attach);
+       dma_buf_put(dmabuf);
 }
 
 struct sg_table *nvhost_dmabuf_pin(struct mem_handle *handle)