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


Groups > linux.kernel > #1735670

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

From Arvind Yadav <arvind.yadav.cs@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2 1/2] [media] coda: Handle return value of kasprintf
Date 2017-09-20 11:50 +0200
Message-ID <urJNL-1dj-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
changes in v2 :
	Calling coda_free_framebuffers to release already allocated buffers.

 drivers/media/platform/coda/coda-bit.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 291c409..bfc4ecf 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -417,6 +417,10 @@ 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) {
+			coda_free_framebuffers(ctx);
+			return -ENOMEM;
+		}
 		ret = coda_alloc_context_buf(ctx, &ctx->internal_frames[i],
 					     size, name);
 		kfree(name);
-- 
1.9.1

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

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

csiph-web