diff mbox series

[RFC,WIP,1/2] media: cedrus: fix double free

Message ID 20210702020129.470720-2-daniel.almeida@collabora.com
State Accepted
Commit fe47b6d7582ad1a608d8341c3e02c3e06f5678e6
Headers show
Series cedrus: h264: add support for dynamically allocated ctrl arrays | expand

Commit Message

Daniel Almeida July 2, 2021, 2:01 a.m. UTC
From: Daniel Almeida <daniel.almeida@collabora.com>

If v4l2_ctrl_new_custom fails in cedrus_init_ctrls the error path will
free ctx->ctrls, which is also freed in cedrus release. Fix this by
setting ctx->ctrls to NULL instead of inadvertently removing kfree
calls.

Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
---
 drivers/staging/media/sunxi/cedrus/cedrus.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Hans Verkuil July 19, 2021, 8:17 a.m. UTC | #1
On 02/07/2021 04:01, daniel.almeida@collabora.com wrote:
> From: Daniel Almeida <daniel.almeida@collabora.com>

> 

> If v4l2_ctrl_new_custom fails in cedrus_init_ctrls the error path will

> free ctx->ctrls, which is also freed in cedrus release. Fix this by

> setting ctx->ctrls to NULL instead of inadvertently removing kfree

> calls.


This is just a bug fix, right? Not really an RFC,WIP.

Regards,

	Hans

> 

> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>

> ---

>  drivers/staging/media/sunxi/cedrus/cedrus.c | 1 +

>  1 file changed, 1 insertion(+)

> 

> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c

> index c0d005dafc6c..e72810ace40f 100644

> --- a/drivers/staging/media/sunxi/cedrus/cedrus.c

> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c

> @@ -207,6 +207,7 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx)

>  

>  			v4l2_ctrl_handler_free(hdl);

>  			kfree(ctx->ctrls);

> +			ctx->ctrls = NULL;

>  			return hdl->error;

>  		}

>  

>
diff mbox series

Patch

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index c0d005dafc6c..e72810ace40f 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -207,6 +207,7 @@  static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx)
 
 			v4l2_ctrl_handler_free(hdl);
 			kfree(ctx->ctrls);
+			ctx->ctrls = NULL;
 			return hdl->error;
 		}