linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] media: videobuf2: Return error after allocation failure
@ 2019-02-04 15:01 Souptick Joarder
  2019-02-11  2:12 ` Souptick Joarder
  0 siblings, 1 reply; 5+ messages in thread
From: Souptick Joarder @ 2019-02-04 15:01 UTC (permalink / raw)
  To: pawel, m.szyprowski, kyungmin.park, mchehab, nicolas
  Cc: linux-media, linux-kernel

There is no point to continuing assignment after memory allocation
failed, rather throw error immediately.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
v1 -> v2:
	Corrected typo in change log.

 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;
-- 
1.9.1


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

* Re: [PATCHv2] media: videobuf2: Return error after allocation failure
  2019-02-04 15:01 [PATCHv2] media: videobuf2: Return error after allocation failure Souptick Joarder
@ 2019-02-11  2:12 ` Souptick Joarder
  2019-03-01  3:04   ` Souptick Joarder
  0 siblings, 1 reply; 5+ messages in thread
From: Souptick Joarder @ 2019-02-11  2:12 UTC (permalink / raw)
  To: pawel, Marek Szyprowski, Kyungmin Park, mchehab, Nicolas Dufresne
  Cc: linux-media, linux-kernel

On Mon, Feb 4, 2019 at 8:27 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> There is no point to continuing assignment after memory allocation
> failed, rather throw error immediately.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>

Any comment on this patch ?

> ---
> v1 -> v2:
>         Corrected typo in change log.
>
>  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;
> --
> 1.9.1
>

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

* Re: [PATCHv2] media: videobuf2: Return error after allocation failure
  2019-02-11  2:12 ` Souptick Joarder
@ 2019-03-01  3:04   ` Souptick Joarder
  2019-03-11 15:30     ` Hans Verkuil
  0 siblings, 1 reply; 5+ messages in thread
From: Souptick Joarder @ 2019-03-01  3:04 UTC (permalink / raw)
  To: pawel, Marek Szyprowski, Kyungmin Park, mchehab, Nicolas Dufresne
  Cc: linux-media, linux-kernel

On Mon, Feb 11, 2019 at 7:42 AM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> On Mon, Feb 4, 2019 at 8:27 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
> >
> > There is no point to continuing assignment after memory allocation
> > failed, rather throw error immediately.
> >
> > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
>
> Any comment on this patch ?

If no further comment, can we get this patch in queue for 5.1 ?
>
> > ---
> > v1 -> v2:
> >         Corrected typo in change log.
> >
> >  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;
> > --
> > 1.9.1
> >

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

* Re: [PATCHv2] media: videobuf2: Return error after allocation failure
  2019-03-01  3:04   ` Souptick Joarder
@ 2019-03-11 15:30     ` Hans Verkuil
  2019-03-11 15:31       ` Souptick Joarder
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2019-03-11 15:30 UTC (permalink / raw)
  To: Souptick Joarder, pawel, Marek Szyprowski, Kyungmin Park,
	mchehab, Nicolas Dufresne
  Cc: linux-media, linux-kernel

On 3/1/19 4:04 AM, Souptick Joarder wrote:
> On Mon, Feb 11, 2019 at 7:42 AM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>>
>> On Mon, Feb 4, 2019 at 8:27 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>>>
>>> There is no point to continuing assignment after memory allocation
>>> failed, rather throw error immediately.
>>>
>>> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
>>
>> Any comment on this patch ?
> 
> If no further comment, can we get this patch in queue for 5.1 ?

5.1 was too late, but it will certainly go into 5.2.

Regards,

	Hans

>>
>>> ---
>>> v1 -> v2:
>>>         Corrected typo in change log.
>>>
>>>  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;
>>> --
>>> 1.9.1
>>>


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

* Re: [PATCHv2] media: videobuf2: Return error after allocation failure
  2019-03-11 15:30     ` Hans Verkuil
@ 2019-03-11 15:31       ` Souptick Joarder
  0 siblings, 0 replies; 5+ messages in thread
From: Souptick Joarder @ 2019-03-11 15:31 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: pawel, Marek Szyprowski, Kyungmin Park, mchehab,
	Nicolas Dufresne, linux-media, linux-kernel

On Mon, Mar 11, 2019 at 9:00 PM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
> On 3/1/19 4:04 AM, Souptick Joarder wrote:
> > On Mon, Feb 11, 2019 at 7:42 AM Souptick Joarder <jrdr.linux@gmail.com> wrote:
> >>
> >> On Mon, Feb 4, 2019 at 8:27 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
> >>>
> >>> There is no point to continuing assignment after memory allocation
> >>> failed, rather throw error immediately.
> >>>
> >>> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> >>
> >> Any comment on this patch ?
> >
> > If no further comment, can we get this patch in queue for 5.1 ?
>
> 5.1 was too late, but it will certainly go into 5.2.

Thanks.
>
> Regards,
>
>         Hans
>
> >>
> >>> ---
> >>> v1 -> v2:
> >>>         Corrected typo in change log.
> >>>
> >>>  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;
> >>> --
> >>> 1.9.1
> >>>
>

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

end of thread, other threads:[~2019-03-11 15:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-04 15:01 [PATCHv2] media: videobuf2: Return error after allocation failure Souptick Joarder
2019-02-11  2:12 ` Souptick Joarder
2019-03-01  3:04   ` Souptick Joarder
2019-03-11 15:30     ` Hans Verkuil
2019-03-11 15:31       ` Souptick Joarder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).