RE: [PATCH] media: vb2: add a check for uninitialized buffer

2011-10-18 Thread Marek Szyprowski
Hello,

On Wednesday, October 19, 2011 8:03 AM Pawel Osciak wrote:

> Hi Marek,
> I think there is a typo in this patch:
> 
> On Wed, Oct 12, 2011 at 09:12, Marek Szyprowski
>  wrote:
> > __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 
> > Signed-off-by: Kyungmin Park 
> > CC: Pawel Osciak 
> >
> > ---
> >  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 d8affb8..cdbbab7 100644
> > --- a/drivers/media/video/videobuf2-core.c
> > +++ b/drivers/media/video/videobuf2-core.c
> > @@ -284,14 +284,14 @@ static bool __buffer_in_use(struct vb2_queue *q, 
> > struct vb2_buffer
> *vb)
> >  {
> >        unsigned int plane;
> >        for (plane = 0; plane < vb->num_planes; ++plane) {
> > +               void mem_priv = vb->planes[plane].mem_priv;
> 
> Shouldn't this be void * instead of just void?

Yes, it should be. It looks that I've posted an older version. In the pull 
request there is a correct version.

> >                /*
> >                 * If num_users() has not been provided, call_memop
> >                 * will return 0, apparently nobody cares about this
> >                 * case anyway. If num_users() returns more than 1,
> >                 * we are not the only user of the plane's memory.
> >                 */
> > -               if (call_memop(q, plane, num_users,
> > -                               vb->planes[plane].mem_priv) > 1)
> > +               if (mem_priv && call_memop(q, plane, num_users, mem_priv) > 
> > 1)
> >                        return true;
> >        }
> >        return false;
> > --
> > 1.7.1.569.g6f426

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] media: vb2: add a check for uninitialized buffer

2011-10-18 Thread Pawel Osciak
Hi Marek,
I think there is a typo in this patch:

On Wed, Oct 12, 2011 at 09:12, Marek Szyprowski
 wrote:
> __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 
> Signed-off-by: Kyungmin Park 
> CC: Pawel Osciak 
>
> ---
>  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 d8affb8..cdbbab7 100644
> --- a/drivers/media/video/videobuf2-core.c
> +++ b/drivers/media/video/videobuf2-core.c
> @@ -284,14 +284,14 @@ static bool __buffer_in_use(struct vb2_queue *q, struct 
> vb2_buffer *vb)
>  {
>        unsigned int plane;
>        for (plane = 0; plane < vb->num_planes; ++plane) {
> +               void mem_priv = vb->planes[plane].mem_priv;

Shouldn't this be void * instead of just void?

>                /*
>                 * If num_users() has not been provided, call_memop
>                 * will return 0, apparently nobody cares about this
>                 * case anyway. If num_users() returns more than 1,
>                 * we are not the only user of the plane's memory.
>                 */
> -               if (call_memop(q, plane, num_users,
> -                               vb->planes[plane].mem_priv) > 1)
> +               if (mem_priv && call_memop(q, plane, num_users, mem_priv) > 1)
>                        return true;
>        }
>        return false;
> --
> 1.7.1.569.g6f426
>
>


-- 
Best regards,
Pawel Osciak
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: vb2: add a check for uninitialized buffer

2011-10-12 Thread Marek Szyprowski
__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 
Signed-off-by: Kyungmin Park 
CC: Pawel Osciak 

---
 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 d8affb8..cdbbab7 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -284,14 +284,14 @@ static bool __buffer_in_use(struct vb2_queue *q, struct 
vb2_buffer *vb)
 {
unsigned int plane;
for (plane = 0; plane < vb->num_planes; ++plane) {
+   void mem_priv = vb->planes[plane].mem_priv;
/*
 * If num_users() has not been provided, call_memop
 * will return 0, apparently nobody cares about this
 * case anyway. If num_users() returns more than 1,
 * we are not the only user of the plane's memory.
 */
-   if (call_memop(q, plane, num_users,
-   vb->planes[plane].mem_priv) > 1)
+   if (mem_priv && call_memop(q, plane, num_users, mem_priv) > 1)
return true;
}
return false;
-- 
1.7.1.569.g6f426

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html