diff mbox series

media: videobuf2: Return error after allocation failure

Message ID 20190203133608.GA26010@jordon-HP-15-Notebook-PC (mailing list archive)
State New, archived
Headers show
Series media: videobuf2: Return error after allocation failure | expand

Commit Message

Souptick Joarder Feb. 3, 2019, 1:36 p.m. UTC
There is no point to continuing assignemnt after memory allocation
failed, rather throw error immediately.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Nicolas Dufresne Feb. 3, 2019, 9:54 p.m. UTC | #1
Le dimanche 03 février 2019 à 19:06 +0530, Souptick Joarder a écrit :
> There is no point to continuing assignemnt after memory allocation

assignemnt -> assignment.

> failed, rather throw error immediately.
> 
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> ---
>  drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
> index 6dfbd5b..d3f71e2 100644
> --- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
> +++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
> @@ -46,16 +46,16 @@ static void *vb2_vmalloc_alloc(struct device *dev, unsigned long attrs,
>  
>  	buf->size = size;
>  	buf->vaddr = vmalloc_user(buf->size);
> -	buf->dma_dir = dma_dir;
> -	buf->handler.refcount = &buf->refcount;
> -	buf->handler.put = vb2_vmalloc_put;
> -	buf->handler.arg = buf;
>  
>  	if (!buf->vaddr) {
>  		pr_debug("vmalloc of size %ld failed\n", buf->size);
>  		kfree(buf);
>  		return ERR_PTR(-ENOMEM);
>  	}
> +	buf->dma_dir = dma_dir;
> +	buf->handler.refcount = &buf->refcount;
> +	buf->handler.put = vb2_vmalloc_put;
> +	buf->handler.arg = buf;
>  
>  	refcount_set(&buf->refcount, 1);
>  	return buf;
Souptick Joarder Feb. 4, 2019, 2:03 a.m. UTC | #2
On Mon, Feb 4, 2019 at 3:25 AM Nicolas Dufresne <nicolas@ndufresne.ca> wrote:
>
> Le dimanche 03 février 2019 à 19:06 +0530, Souptick Joarder a écrit :
> > There is no point to continuing assignemnt after memory allocation
>
> assignemnt -> assignment.

Ah, type.
>
> > failed, rather throw error immediately.
> >
> > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> > ---
> >  drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
> > index 6dfbd5b..d3f71e2 100644
> > --- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
> > +++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
> > @@ -46,16 +46,16 @@ static void *vb2_vmalloc_alloc(struct device *dev, unsigned long attrs,
> >
> >       buf->size = size;
> >       buf->vaddr = vmalloc_user(buf->size);
> > -     buf->dma_dir = dma_dir;
> > -     buf->handler.refcount = &buf->refcount;
> > -     buf->handler.put = vb2_vmalloc_put;
> > -     buf->handler.arg = buf;
> >
> >       if (!buf->vaddr) {
> >               pr_debug("vmalloc of size %ld failed\n", buf->size);
> >               kfree(buf);
> >               return ERR_PTR(-ENOMEM);
> >       }
> > +     buf->dma_dir = dma_dir;
> > +     buf->handler.refcount = &buf->refcount;
> > +     buf->handler.put = vb2_vmalloc_put;
> > +     buf->handler.arg = buf;
> >
> >       refcount_set(&buf->refcount, 1);
> >       return buf;
>
diff mbox series

Patch

diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
index 6dfbd5b..d3f71e2 100644
--- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
+++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
@@ -46,16 +46,16 @@  static void *vb2_vmalloc_alloc(struct device *dev, unsigned long attrs,
 
 	buf->size = size;
 	buf->vaddr = vmalloc_user(buf->size);
-	buf->dma_dir = dma_dir;
-	buf->handler.refcount = &buf->refcount;
-	buf->handler.put = vb2_vmalloc_put;
-	buf->handler.arg = buf;
 
 	if (!buf->vaddr) {
 		pr_debug("vmalloc of size %ld failed\n", buf->size);
 		kfree(buf);
 		return ERR_PTR(-ENOMEM);
 	}
+	buf->dma_dir = dma_dir;
+	buf->handler.refcount = &buf->refcount;
+	buf->handler.put = vb2_vmalloc_put;
+	buf->handler.arg = buf;
 
 	refcount_set(&buf->refcount, 1);
 	return buf;