diff mbox

[4/4] drivers/media/video: Eliminate use after free

Message ID Pine.LNX.4.64.1005151146370.15566@ask.diku.dk (mailing list archive)
State Superseded
Headers show

Commit Message

Julia Lawall May 15, 2010, 9:46 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c
index baf211b..fb73f34 100644
--- a/drivers/media/video/mem2mem_testdev.c
+++ b/drivers/media/video/mem2mem_testdev.c
@@ -858,6 +858,7 @@  static int m2mtest_open(struct file *file)
 {
 	struct m2mtest_dev *dev = video_drvdata(file);
 	struct m2mtest_ctx *ctx = NULL;
+	int err;
 
 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
 	if (!ctx)
@@ -871,8 +872,9 @@  static int m2mtest_open(struct file *file)
 
 	ctx->m2m_ctx = v4l2_m2m_ctx_init(ctx, dev->m2m_dev, queue_init);
 	if (IS_ERR(ctx->m2m_ctx)) {
+		err = PTR_ERR(ctx->m2m_ctx);
 		kfree(ctx);
-		return PTR_ERR(ctx->m2m_ctx);
+		return err;
 	}
 
 	atomic_inc(&dev->num_inst);