All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] videobuf2-dma-contig: return NULL if alloc fails
@ 2011-06-23 13:20 Jun Nie
  2011-07-12  5:21 ` Jun Nie
  0 siblings, 1 reply; 3+ messages in thread
From: Jun Nie @ 2011-06-23 13:20 UTC (permalink / raw)
  To: Pawel Osciak, Hans Verkuil, linux-media

return NULL if alloc fails to avoid taking error code as
buffer pointer

Signed-off-by: Jun Nie <njun@marvell.com>
---
 drivers/media/video/videobuf2-dma-contig.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/videobuf2-dma-contig.c
b/drivers/media/video/videobuf2-dma-contig.c
index a790a5f..8e8c7aa 100644
--- a/drivers/media/video/videobuf2-dma-contig.c
+++ b/drivers/media/video/videobuf2-dma-contig.c
@@ -40,7 +40,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx,
unsigned long size)

 	buf = kzalloc(sizeof *buf, GFP_KERNEL);
 	if (!buf)
-		return ERR_PTR(-ENOMEM);
+		return NULL;

 	buf->vaddr = dma_alloc_coherent(conf->dev, size, &buf->paddr,
 					GFP_KERNEL);
@@ -48,7 +48,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx,
unsigned long size)
 		dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n",
 			size);
 		kfree(buf);
-		return ERR_PTR(-ENOMEM);
+		return NULL;
 	}

 	buf->conf = conf;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [media] videobuf2-dma-contig: return NULL if alloc fails
  2011-06-23 13:20 [PATCH] [media] videobuf2-dma-contig: return NULL if alloc fails Jun Nie
@ 2011-07-12  5:21 ` Jun Nie
  2011-07-12  8:03   ` Guennadi Liakhovetski
  0 siblings, 1 reply; 3+ messages in thread
From: Jun Nie @ 2011-07-12  5:21 UTC (permalink / raw)
  To: Pawel Osciak, Hans Verkuil, linux-media, Guennadi Liakhovetski

2011/6/23 Jun Nie <niej0001@gmail.com>:
> return NULL if alloc fails to avoid taking error code as
> buffer pointer
>
> Signed-off-by: Jun Nie <njun@marvell.com>
> ---
>  drivers/media/video/videobuf2-dma-contig.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/video/videobuf2-dma-contig.c
> b/drivers/media/video/videobuf2-dma-contig.c
> index a790a5f..8e8c7aa 100644
> --- a/drivers/media/video/videobuf2-dma-contig.c
> +++ b/drivers/media/video/videobuf2-dma-contig.c
> @@ -40,7 +40,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx,
> unsigned long size)
>
>        buf = kzalloc(sizeof *buf, GFP_KERNEL);
>        if (!buf)
> -               return ERR_PTR(-ENOMEM);
> +               return NULL;
>
>        buf->vaddr = dma_alloc_coherent(conf->dev, size, &buf->paddr,
>                                        GFP_KERNEL);
> @@ -48,7 +48,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx,
> unsigned long size)
>                dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n",
>                        size);
>                kfree(buf);
> -               return ERR_PTR(-ENOMEM);
> +               return NULL;
>        }
>
>        buf->conf = conf;
> --
> 1.7.0.4
>

How do you think about this fix?
Thanks!

Jun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [media] videobuf2-dma-contig: return NULL if alloc fails
  2011-07-12  5:21 ` Jun Nie
@ 2011-07-12  8:03   ` Guennadi Liakhovetski
  0 siblings, 0 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2011-07-12  8:03 UTC (permalink / raw)
  To: Jun Nie; +Cc: Pawel Osciak, Hans Verkuil, linux-media

On Tue, 12 Jul 2011, Jun Nie wrote:

> 2011/6/23 Jun Nie <niej0001@gmail.com>:
> > return NULL if alloc fails to avoid taking error code as
> > buffer pointer
> >
> > Signed-off-by: Jun Nie <njun@marvell.com>

It shouldn't be needed with this:

https://patchwork.kernel.org/patch/654861/

Thanks
Guennadi

> > ---
> >  drivers/media/video/videobuf2-dma-contig.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/video/videobuf2-dma-contig.c
> > b/drivers/media/video/videobuf2-dma-contig.c
> > index a790a5f..8e8c7aa 100644
> > --- a/drivers/media/video/videobuf2-dma-contig.c
> > +++ b/drivers/media/video/videobuf2-dma-contig.c
> > @@ -40,7 +40,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx,
> > unsigned long size)
> >
> >        buf = kzalloc(sizeof *buf, GFP_KERNEL);
> >        if (!buf)
> > -               return ERR_PTR(-ENOMEM);
> > +               return NULL;
> >
> >        buf->vaddr = dma_alloc_coherent(conf->dev, size, &buf->paddr,
> >                                        GFP_KERNEL);
> > @@ -48,7 +48,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx,
> > unsigned long size)
> >                dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n",
> >                        size);
> >                kfree(buf);
> > -               return ERR_PTR(-ENOMEM);
> > +               return NULL;
> >        }
> >
> >        buf->conf = conf;
> > --
> > 1.7.0.4
> >
> 
> How do you think about this fix?
> Thanks!
> 
> Jun
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-12  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-23 13:20 [PATCH] [media] videobuf2-dma-contig: return NULL if alloc fails Jun Nie
2011-07-12  5:21 ` Jun Nie
2011-07-12  8:03   ` Guennadi Liakhovetski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.