diff mbox

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

Message ID 5533660490db4a91bb25e3984c3d6bd20eb230f6.1505899966.git.arvind.yadav.cs@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arvind Yadav Sept. 20, 2017, 9:40 a.m. UTC
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(+)

Comments

Philipp Zabel Sept. 20, 2017, 10:04 a.m. UTC | #1
On Wed, 2017-09-20 at 15:10 +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>
---
> changes in v2 :
> 	Calling coda_free_framebuffers to release already allocated buffers.

Thanks,

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp
diff mbox

Patch

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