Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1735600 > unrolled thread

[PATCH 1/2] [media] coda: Handle return value of kasprintf

Started byArvind Yadav <arvind.yadav.cs@gmail.com>
First post2017-09-20 09:40 +0200
Last post2017-09-20 10:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/2] [media] coda: Handle return value of kasprintf Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-09-20 09:40 +0200
    Re: [PATCH 1/2] [media] coda: Handle return value of kasprintf Philipp Zabel <p.zabel@pengutronix.de> - 2017-09-20 10:40 +0200

#1735600 — [PATCH 1/2] [media] coda: Handle return value of kasprintf

FromArvind Yadav <arvind.yadav.cs@gmail.com>
Date2017-09-20 09:40 +0200
Subject[PATCH 1/2] [media] coda: Handle return value of kasprintf
Message-ID<urHLX-8md-1@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1735631

FromPhilipp Zabel <p.zabel@pengutronix.de>
Date2017-09-20 10:40 +0200
Message-ID<urII2-xz-21@gated-at.bofh.it>
In reply to#1735600
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web