media: fdp1: Fix a memory leak bug
authorWenwen Wang <wenwen@cs.uga.edu>
Sun, 18 Aug 2019 05:58:53 +0000 (02:58 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 26 Aug 2019 13:41:17 +0000 (10:41 -0300)
In fdp1_open(), 'ctx' is allocated through kzalloc(). However, it is not
deallocated if v4l2_ctrl_new_std() fails, leading to a memory leak bug. To
fix this issue, free 'ctx' before going to the 'done' label.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/rcar_fdp1.c

index c23ec12..cb93a13 100644 (file)
@@ -2122,6 +2122,7 @@ static int fdp1_open(struct file *file)
        if (ctx->hdl.error) {
                ret = ctx->hdl.error;
                v4l2_ctrl_handler_free(&ctx->hdl);
+               kfree(ctx);
                goto done;
        }