linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx
@ 2021-05-11  4:09 dillon.minfei
  2021-05-25  5:26 ` Dillon Min
  2021-05-26 13:41 ` Hans Verkuil
  0 siblings, 2 replies; 4+ messages in thread
From: dillon.minfei @ 2021-05-11  4:09 UTC (permalink / raw)
  To: mchehab+huawei, hverkuil-cisco, a.hajda
  Cc: linux-arm-kernel, linux-media, linux-kernel, Dillon Min

From: Dillon Min <dillon.minfei@gmail.com>

The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open()
should be freed from g2d_release() when it's not used.

Fix it

Fixes: 918847341af0 ("[media] v4l: add G2D driver for s5p device family")
Signed-off-by: Dillon Min <dillon.minfei@gmail.com>
---
 drivers/media/platform/s5p-g2d/g2d.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 15bcb7f6e113..0818fdd3e984 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -279,6 +279,9 @@ static int g2d_release(struct file *file)
 	v4l2_ctrl_handler_free(&ctx->ctrl_handler);
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
+	mutex_lock(&dev->mutex);
+	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
+	mutex_unlock(&dev->mutex);
 	kfree(ctx);
 	v4l2_info(&dev->v4l2_dev, "instance closed\n");
 	return 0;
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx
  2021-05-11  4:09 [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx dillon.minfei
@ 2021-05-25  5:26 ` Dillon Min
  2021-05-26 13:41 ` Hans Verkuil
  1 sibling, 0 replies; 4+ messages in thread
From: Dillon Min @ 2021-05-25  5:26 UTC (permalink / raw)
  To: mchehab+huawei, hverkuil-cisco, a.hajda
  Cc: Linux ARM, linux-media, Linux Kernel Mailing List, Mauro Carvalho Chehab

Just a kind ping.

Thanks.
Dillon,

On Tue, May 11, 2021 at 12:09 PM <dillon.minfei@gmail.com> wrote:
>
> From: Dillon Min <dillon.minfei@gmail.com>
>
> The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open()
> should be freed from g2d_release() when it's not used.
>
> Fix it
>
> Fixes: 918847341af0 ("[media] v4l: add G2D driver for s5p device family")
> Signed-off-by: Dillon Min <dillon.minfei@gmail.com>
> ---
>  drivers/media/platform/s5p-g2d/g2d.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
> index 15bcb7f6e113..0818fdd3e984 100644
> --- a/drivers/media/platform/s5p-g2d/g2d.c
> +++ b/drivers/media/platform/s5p-g2d/g2d.c
> @@ -279,6 +279,9 @@ static int g2d_release(struct file *file)
>         v4l2_ctrl_handler_free(&ctx->ctrl_handler);
>         v4l2_fh_del(&ctx->fh);
>         v4l2_fh_exit(&ctx->fh);
> +       mutex_lock(&dev->mutex);
> +       v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
> +       mutex_unlock(&dev->mutex);
>         kfree(ctx);
>         v4l2_info(&dev->v4l2_dev, "instance closed\n");
>         return 0;
> --
> 2.7.4
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx
  2021-05-11  4:09 [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx dillon.minfei
  2021-05-25  5:26 ` Dillon Min
@ 2021-05-26 13:41 ` Hans Verkuil
  2021-05-26 15:13   ` Dillon Min
  1 sibling, 1 reply; 4+ messages in thread
From: Hans Verkuil @ 2021-05-26 13:41 UTC (permalink / raw)
  To: dillon.minfei, mchehab+huawei, a.hajda
  Cc: linux-arm-kernel, linux-media, linux-kernel

On 11/05/2021 06:09, dillon.minfei@gmail.com wrote:
> From: Dillon Min <dillon.minfei@gmail.com>
> 
> The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open()
> should be freed from g2d_release() when it's not used.
> 
> Fix it
> 
> Fixes: 918847341af0 ("[media] v4l: add G2D driver for s5p device family")
> Signed-off-by: Dillon Min <dillon.minfei@gmail.com>
> ---
>  drivers/media/platform/s5p-g2d/g2d.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
> index 15bcb7f6e113..0818fdd3e984 100644
> --- a/drivers/media/platform/s5p-g2d/g2d.c
> +++ b/drivers/media/platform/s5p-g2d/g2d.c
> @@ -279,6 +279,9 @@ static int g2d_release(struct file *file)
>  	v4l2_ctrl_handler_free(&ctx->ctrl_handler);
>  	v4l2_fh_del(&ctx->fh);
>  	v4l2_fh_exit(&ctx->fh);
> +	mutex_lock(&dev->mutex);
> +	v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
> +	mutex_unlock(&dev->mutex);

This should be moved up to just before the v4l2_ctrl_handler_free() call.

Regards,

	Hans

>  	kfree(ctx);
>  	v4l2_info(&dev->v4l2_dev, "instance closed\n");
>  	return 0;
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx
  2021-05-26 13:41 ` Hans Verkuil
@ 2021-05-26 15:13   ` Dillon Min
  0 siblings, 0 replies; 4+ messages in thread
From: Dillon Min @ 2021-05-26 15:13 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: mchehab+huawei, a.hajda, Linux ARM, linux-media,
	Linux Kernel Mailing List

Hi Hans,

Thanks for the reply.

On Wed, May 26, 2021 at 9:41 PM Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote:
>
> On 11/05/2021 06:09, dillon.minfei@gmail.com wrote:
> > From: Dillon Min <dillon.minfei@gmail.com>
> >
> > The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open()
> > should be freed from g2d_release() when it's not used.
> >
> > Fix it
> >
> > Fixes: 918847341af0 ("[media] v4l: add G2D driver for s5p device family")
> > Signed-off-by: Dillon Min <dillon.minfei@gmail.com>
> > ---
> >  drivers/media/platform/s5p-g2d/g2d.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
> > index 15bcb7f6e113..0818fdd3e984 100644
> > --- a/drivers/media/platform/s5p-g2d/g2d.c
> > +++ b/drivers/media/platform/s5p-g2d/g2d.c
> > @@ -279,6 +279,9 @@ static int g2d_release(struct file *file)
> >       v4l2_ctrl_handler_free(&ctx->ctrl_handler);
> >       v4l2_fh_del(&ctx->fh);
> >       v4l2_fh_exit(&ctx->fh);
> > +     mutex_lock(&dev->mutex);
> > +     v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
> > +     mutex_unlock(&dev->mutex);
>
> This should be moved up to just before the v4l2_ctrl_handler_free() call.

On my mistake, thanks for pointing it out. will be moved up to
v4l2_ctrl_handler_free() in v2.

Best regards.
Dillon

>
> Regards,
>
>         Hans
>
> >       kfree(ctx);
> >       v4l2_info(&dev->v4l2_dev, "instance closed\n");
> >       return 0;
> >
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-26 16:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11  4:09 [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx dillon.minfei
2021-05-25  5:26 ` Dillon Min
2021-05-26 13:41 ` Hans Verkuil
2021-05-26 15:13   ` Dillon Min

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).