From: Dillon Min <dillon.minfei@gmail.com> To: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: mchehab+huawei@kernel.org, a.hajda@samsung.com, Linux ARM <linux-arm-kernel@lists.infradead.org>, linux-media <linux-media@vger.kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx Date: Wed, 26 May 2021 23:13:19 +0800 [thread overview] Message-ID: <CAL9mu0+bTrVsUVmZv8jFWxP1Wkcb7VQoj3k3j6Yzhe5W=5sY3Q@mail.gmail.com> (raw) In-Reply-To: <2193bb5c-89c3-cb1a-f2ef-1389ccfb7d61@xs4all.nl> 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; > > >
WARNING: multiple messages have this Message-ID (diff)
From: Dillon Min <dillon.minfei@gmail.com> To: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: mchehab+huawei@kernel.org, a.hajda@samsung.com, Linux ARM <linux-arm-kernel@lists.infradead.org>, linux-media <linux-media@vger.kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx Date: Wed, 26 May 2021 23:13:19 +0800 [thread overview] Message-ID: <CAL9mu0+bTrVsUVmZv8jFWxP1Wkcb7VQoj3k3j6Yzhe5W=5sY3Q@mail.gmail.com> (raw) In-Reply-To: <2193bb5c-89c3-cb1a-f2ef-1389ccfb7d61@xs4all.nl> 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
next prev parent reply other threads:[~2021-05-26 15:14 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-11 4:09 [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx dillon.minfei 2021-05-11 4:09 ` dillon.minfei 2021-05-25 5:26 ` Dillon Min 2021-05-25 5:26 ` Dillon Min 2021-05-26 13:41 ` Hans Verkuil 2021-05-26 13:41 ` Hans Verkuil 2021-05-26 15:13 ` Dillon Min [this message] 2021-05-26 15:13 ` Dillon Min
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAL9mu0+bTrVsUVmZv8jFWxP1Wkcb7VQoj3k3j6Yzhe5W=5sY3Q@mail.gmail.com' \ --to=dillon.minfei@gmail.com \ --cc=a.hajda@samsung.com \ --cc=hverkuil-cisco@xs4all.nl \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=mchehab+huawei@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.