fimc-is-2: move to the new dma-buf-container
authorCho KyongHo <pullip.cho@samsung.com>
Fri, 25 May 2018 11:33:41 +0000 (20:33 +0900)
committerEunyoung Lee <ey470.lee@samsung.com>
Tue, 19 Jun 2018 08:43:38 +0000 (17:43 +0900)
The new, working dma-buf-container is introduced by the commit
ee1d9055d ('dma-buf: introduce dma-buf container'). It still supports
the same API functions but the contexts are slightly changed because
the design of dma-buf-container is changed.

Specifically, dmabuf_container_get_count() now returns -EINVAL instead
of 0 for the dma-bufs that is not a dma-buf-container. This change of
return value comes from the fact that dma-buf-container allows having
no dma-buf by its design although it is impossible to create an empty
dma-buf-container in practice.

Change-Id: I8c8c6698a513e6c18bbc43a4734594a484028699
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/media/platform/exynos/fimc-is2/fimc-is-video.c

index a9b936dbe5889f19726b2462a1feea37d95fe859..3084039c88a256d0af51bc91a42f96dd07d24dc2 100644 (file)
@@ -29,7 +29,7 @@
 #include <linux/syscalls.h>
 #include <linux/videodev2_exynos_media.h>
 #include <linux/dma-buf.h>
-#include <linux/dmabuf_container.h>
+#include <linux/dma-buf-container.h>
 
 #include <media/videobuf2-v4l2.h>
 #include <media/v4l2-ctrls.h>
@@ -944,6 +944,22 @@ int fimc_is_queue_buffer_queue(struct fimc_is_queue *queue,
 
                /* get the buffer count in the dmabuf_container */
                batch_size = dmabuf_container_get_count(dmabuf);
+               if (batch_size == 0) {
+                       /*
+                        * FIXME: exiting this function here causes leak of
+                        * dma-bufs. This also applies to the above return
+                        * statement and all 'goto exit' statements below.
+                        * Please fix this by the right person in charge.
+                        */
+                       err("%s Empty dmabuf-container of fd %d\n", __func__,
+                           vb->planes[i].m.fd);
+                       dma_buf_put(dmabuf);
+                       return (u32)-ENOMEM;
+               }
+
+               if (batch_size < 0)
+                       batch_size = 0;
+
                if (batch_size > 0) {
                        /* traverse and check the buffers in dmabuf_container */
                        for (buf_i = 0; buf_i < batch_size; buf_i++) {