linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] [media] Handle return value of kasprintf
@ 2017-09-20  7:37 Arvind Yadav
  2017-09-20  7:37 ` [PATCH 1/2] [media] coda: " Arvind Yadav
  2017-09-20  7:37 ` [PATCH 2/2] [media] cx23885: " Arvind Yadav
  0 siblings, 2 replies; 4+ messages in thread
From: Arvind Yadav @ 2017-09-20  7:37 UTC (permalink / raw)
  To: p.zabel, mchehab, hans.verkuil, sean, andi.shyti
  Cc: linux-media, linux-kernel

kasprintf() can fail here and we must check its return value.

Arvind Yadav (2):
  [PATCH 1/2][media] coda: Handle return value of kasprintf
  [PATCH 2/2][media] cx23885: Handle return value of kasprintf

 drivers/media/pci/cx23885/cx23885-input.c | 15 +++++++++++++--
 drivers/media/platform/coda/coda-bit.c    |  3 +++
 2 files changed, 16 insertions(+), 2 deletions(-)

-- 
1.9.1

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

* [PATCH 1/2] [media] coda: Handle return value of kasprintf
  2017-09-20  7:37 [PATCH 0/2] [media] Handle return value of kasprintf Arvind Yadav
@ 2017-09-20  7:37 ` Arvind Yadav
  2017-09-20  8:30   ` Philipp Zabel
  2017-09-20  7:37 ` [PATCH 2/2] [media] cx23885: " Arvind Yadav
  1 sibling, 1 reply; 4+ messages in thread
From: Arvind Yadav @ 2017-09-20  7:37 UTC (permalink / raw)
  To: p.zabel, mchehab, hans.verkuil, sean, andi.shyti
  Cc: linux-media, linux-kernel

kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/media/platform/coda/coda-bit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 291c409..8d78183 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -417,6 +417,9 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,
 		    dev->devtype->product != CODA_DX6)
 			size += ysize / 4;
 		name = kasprintf(GFP_KERNEL, "fb%d", i);
+		if (!name)
+			return -ENOMEM;
+
 		ret = coda_alloc_context_buf(ctx, &ctx->internal_frames[i],
 					     size, name);
 		kfree(name);
-- 
1.9.1

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

* [PATCH 2/2] [media] cx23885: Handle return value of kasprintf
  2017-09-20  7:37 [PATCH 0/2] [media] Handle return value of kasprintf Arvind Yadav
  2017-09-20  7:37 ` [PATCH 1/2] [media] coda: " Arvind Yadav
@ 2017-09-20  7:37 ` Arvind Yadav
  1 sibling, 0 replies; 4+ messages in thread
From: Arvind Yadav @ 2017-09-20  7:37 UTC (permalink / raw)
  To: p.zabel, mchehab, hans.verkuil, sean, andi.shyti
  Cc: linux-media, linux-kernel

kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/media/pci/cx23885/cx23885-input.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 944b7083..0f4e542 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -340,14 +340,23 @@ int cx23885_input_init(struct cx23885_dev *dev)
 	kernel_ir->cx = dev;
 	kernel_ir->name = kasprintf(GFP_KERNEL, "cx23885 IR (%s)",
 				    cx23885_boards[dev->board].name);
+	if (!kernel_ir->name) {
+		ret = -ENOMEM;
+		goto err_out_free;
+	}
+
 	kernel_ir->phys = kasprintf(GFP_KERNEL, "pci-%s/ir0",
 				    pci_name(dev->pci));
+	if (!kernel_ir->phys) {
+		ret = -ENOMEM;
+		goto err_out_free_name;
+	}
 
 	/* input device */
 	rc = rc_allocate_device(RC_DRIVER_IR_RAW);
 	if (!rc) {
 		ret = -ENOMEM;
-		goto err_out_free;
+		goto err_out_free_phys;
 	}
 
 	kernel_ir->rc = rc;
@@ -382,9 +391,11 @@ int cx23885_input_init(struct cx23885_dev *dev)
 	cx23885_input_ir_stop(dev);
 	dev->kernel_ir = NULL;
 	rc_free_device(rc);
-err_out_free:
+err_out_free_phys:
 	kfree(kernel_ir->phys);
+err_out_free_name:
 	kfree(kernel_ir->name);
+err_out_free:
 	kfree(kernel_ir);
 	return ret;
 }
-- 
1.9.1

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

* Re: [PATCH 1/2] [media] coda: Handle return value of kasprintf
  2017-09-20  7:37 ` [PATCH 1/2] [media] coda: " Arvind Yadav
@ 2017-09-20  8:30   ` Philipp Zabel
  0 siblings, 0 replies; 4+ messages in thread
From: Philipp Zabel @ 2017-09-20  8:30 UTC (permalink / raw)
  To: Arvind Yadav, mchehab, hans.verkuil, sean, andi.shyti
  Cc: linux-media, linux-kernel

Hi Arvind,

On Wed, 2017-09-20 at 13:07 +0530, Arvind Yadav wrote:
> kasprintf() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/media/platform/coda/coda-bit.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
> index 291c409..8d78183 100644
> --- a/drivers/media/platform/coda/coda-bit.c
> +++ b/drivers/media/platform/coda/coda-bit.c
> @@ -417,6 +417,9 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,
> >  		    dev->devtype->product != CODA_DX6)
> >  			size += ysize / 4;
> >  		name = kasprintf(GFP_KERNEL, "fb%d", i);
> +		if (!name)
> +			return -ENOMEM;
> +

Thank you for the patch. Instead of just returning here, this should
also call coda_free_framebuffers to release already allocated buffers in
earlier iterations of the loop.

regards
Philipp

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

end of thread, other threads:[~2017-09-20  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-20  7:37 [PATCH 0/2] [media] Handle return value of kasprintf Arvind Yadav
2017-09-20  7:37 ` [PATCH 1/2] [media] coda: " Arvind Yadav
2017-09-20  8:30   ` Philipp Zabel
2017-09-20  7:37 ` [PATCH 2/2] [media] cx23885: " Arvind Yadav

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).