diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2011-10-12 12:09:53 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-08 05:59:33 -0500 |
commit | 2c2dd6ac738d8a22def46e073fb7383cac8fa180 (patch) | |
tree | edacdfe8a4392fca7caae99e2cd72368179bb118 | |
parent | e836a1c078e230dd5a94bb086b186c2be3ec6a84 (diff) |
[media] media: vb2: add a check for uninitialized buffer
__buffer_in_use() might be called for empty/uninitialized buffer in the
following scenario: REQBUF(n, USER_PTR), QUERYBUF(). This patch fixes
kernel ops in such case.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/videobuf2-core.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 979e544388cb..9bb92145ad5a 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c | |||
@@ -296,14 +296,14 @@ static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) | |||
296 | { | 296 | { |
297 | unsigned int plane; | 297 | unsigned int plane; |
298 | for (plane = 0; plane < vb->num_planes; ++plane) { | 298 | for (plane = 0; plane < vb->num_planes; ++plane) { |
299 | void *mem_priv = vb->planes[plane].mem_priv; | ||
299 | /* | 300 | /* |
300 | * If num_users() has not been provided, call_memop | 301 | * If num_users() has not been provided, call_memop |
301 | * will return 0, apparently nobody cares about this | 302 | * will return 0, apparently nobody cares about this |
302 | * case anyway. If num_users() returns more than 1, | 303 | * case anyway. If num_users() returns more than 1, |
303 | * we are not the only user of the plane's memory. | 304 | * we are not the only user of the plane's memory. |
304 | */ | 305 | */ |
305 | if (call_memop(q, plane, num_users, | 306 | if (mem_priv && call_memop(q, plane, num_users, mem_priv) > 1) |
306 | vb->planes[plane].mem_priv) > 1) | ||
307 | return true; | 307 | return true; |
308 | } | 308 | } |
309 | return false; | 309 | return false; |