Skip to contentSkip to conversation

media: videobuf2: Return error after allocation failure

PATCH In review Souptick Joarder 2 participants 5 messages Feb 4, 2019 – Mar 11, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: videobuf2: Return error after allocation failure

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

---
v1 -> v2:
Corrected typo in change log.

 drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/common/videobuf2/videobuf2-vmalloc.c +4 -4
index 6dfbd5b..d3f71e2 100644
@@ -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;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Souptick Joarder

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

Any comment on this patch ?

Quoted 35 lines

---
v1 -> v2:
Corrected typo in change log.

 drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/common/videobuf2/videobuf2-vmalloc.c +4 -5
index 6dfbd5b..d3f71e2 100644
@@ -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

#2 lore raw
Quoted 9 lines · Souptick Joarder
Quoted 5 lines · Souptick Joarder

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

Any comment on this patch ?

If no further comment, can we get this patch in queue for 5.1 ?

Quoted 36 lines
Quoted 36 lines

---
v1 -> v2:
Corrected typo in change log.

 drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/common/videobuf2/videobuf2-vmalloc.c +4 -5
index 6dfbd5b..d3f71e2 100644
@@ -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

#3 lore raw
Quoted 4 lines · Souptick Joarder
Quoted 3 lines · Souptick Joarder
Quoted 1 line · Souptick Joarder
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

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

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

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines

---
v1 -> v2:
Corrected typo in change log.

 drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/common/videobuf2/videobuf2-vmalloc.c +4 -5
index 6dfbd5b..d3f71e2 100644
@@ -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

#4 lore raw
Quoted 9 lines · Hans Verkuil
Quoted 7 lines · Souptick Joarder
Quoted 6 lines · Souptick Joarder
Quoted 4 lines · Souptick Joarder

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

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

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.

Quoted 42 lines

Regards,

Hans

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines

---
v1 -> v2:
Corrected typo in change log.

 drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/common/videobuf2/videobuf2-vmalloc.c +4 -5
index 6dfbd5b..d3f71e2 100644
@@ -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