media: videobuf2: Return error after allocation failure
Subsystems (2)
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
@@ -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
Quoted 5 lines · Souptick Joarder
There is no point to continuing assignment after memory allocation failed, rather throw error immediately.
Signed-off-by Souptick Joarder <[email protected]>
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@@ -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
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.
Signed-off-by Souptick Joarder <[email protected]>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@@ -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
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.
Signed-off-by Souptick Joarder <[email protected]>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@@ -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
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
Signed-off-by Souptick Joarder <[email protected]>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@@ -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