diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-02-28 10:49:18 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-11 05:56:42 -0400 |
commit | fb64dca805f091b52dbe8d6504390f63d961cbbd (patch) | |
tree | b59ed4fbf27469d229bd97159e18d9204d32cfb5 | |
parent | b3379c6201bb3555298cdbf0aa004af260f2a6a4 (diff) |
[media] vb2: properly clean up PREPARED and QUEUED buffers
If __reqbufs was called then existing buffers are freed. However, if that
happens without ever having started STREAMON, but if buffers have been queued,
then the buf_finish op is never called.
Add a call to __vb2_queue_cancel in __reqbufs so that these buffers are
cleaned up there as well.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index ce308f6d2095..17f1d071739c 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -100,6 +100,8 @@ module_param(debug, int, 0644); | |||
100 | #define V4L2_BUFFER_OUT_FLAGS (V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME | \ | 100 | #define V4L2_BUFFER_OUT_FLAGS (V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME | \ |
101 | V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE) | 101 | V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE) |
102 | 102 | ||
103 | static void __vb2_queue_cancel(struct vb2_queue *q); | ||
104 | |||
103 | /** | 105 | /** |
104 | * __vb2_buf_mem_alloc() - allocate video memory for the given buffer | 106 | * __vb2_buf_mem_alloc() - allocate video memory for the given buffer |
105 | */ | 107 | */ |
@@ -802,6 +804,12 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | |||
802 | return -EBUSY; | 804 | return -EBUSY; |
803 | } | 805 | } |
804 | 806 | ||
807 | /* | ||
808 | * Call queue_cancel to clean up any buffers in the PREPARED or | ||
809 | * QUEUED state which is possible if buffers were prepared or | ||
810 | * queued without ever calling STREAMON. | ||
811 | */ | ||
812 | __vb2_queue_cancel(q); | ||
805 | ret = __vb2_queue_free(q, q->num_buffers); | 813 | ret = __vb2_queue_free(q, q->num_buffers); |
806 | if (ret) | 814 | if (ret) |
807 | return ret; | 815 | return ret; |