2019-10-10 13:15:16

by Johan Hovold

[permalink] [raw]
Subject: [PATCH 2/4] media: bdisp: fix memleak on release

If a process is interrupted while accessing the video device and the
device lock is contended, release() could return early and fail to free
related resources.

Note that the return value of the v4l2 release file operation is
ignored.

Fixes: 28ffeebbb7bd ("[media] bdisp: 2D blitter driver using v4l2 mem2mem framework")
Cc: stable <[email protected]> # 4.2
Cc: Fabien Dessenne <[email protected]>
Cc: Hans Verkuil <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Signed-off-by: Johan Hovold <[email protected]>
---
drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index e90f1ba30574..675b5f2b4c2e 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -651,8 +651,7 @@ static int bdisp_release(struct file *file)

dev_dbg(bdisp->dev, "%s\n", __func__);

- if (mutex_lock_interruptible(&bdisp->lock))
- return -ERESTARTSYS;
+ mutex_lock(&bdisp->lock);

v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);

--
2.23.0


2019-10-10 14:15:49

by Fabien DESSENNE

[permalink] [raw]
Subject: Re: [PATCH 2/4] media: bdisp: fix memleak on release

Hi Johan

Thank you for the patch

BR

Fabien


On 10/10/2019 3:13 PM, Johan Hovold wrote:
> If a process is interrupted while accessing the video device and the
> device lock is contended, release() could return early and fail to free
> related resources.
>
> Note that the return value of the v4l2 release file operation is
> ignored.
>
> Fixes: 28ffeebbb7bd ("[media] bdisp: 2D blitter driver using v4l2 mem2mem framework")
> Cc: stable <[email protected]> # 4.2
> Cc: Fabien Dessenne <[email protected]>
> Cc: Hans Verkuil <[email protected]>
> Cc: Mauro Carvalho Chehab <[email protected]>
> Signed-off-by: Johan Hovold <[email protected]>
Reviewed-by: Fabien Dessenne <[email protected]>
> ---
> drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> index e90f1ba30574..675b5f2b4c2e 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
> @@ -651,8 +651,7 @@ static int bdisp_release(struct file *file)
>
> dev_dbg(bdisp->dev, "%s\n", __func__);
>
> - if (mutex_lock_interruptible(&bdisp->lock))
> - return -ERESTARTSYS;
> + mutex_lock(&bdisp->lock);
>
> v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
>