linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
To: Wenwen Wang <wenwen@cs.uga.edu>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	"open list:MEDIA DRIVERS FOR RENESAS - FDP1" 
	<linux-media@vger.kernel.org>,
	"open list:MEDIA DRIVERS FOR RENESAS - FDP1" 
	<linux-renesas-soc@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] media: fdp1: Fix a memory leak bug
Date: Wed, 21 Aug 2019 12:39:20 +0100	[thread overview]
Message-ID: <5cb18e08-4e9b-6ca4-015a-fb21b4f7d504@ideasonboard.com> (raw)
In-Reply-To: <1566107933-3355-1-git-send-email-wenwen@cs.uga.edu>

Hi Wenwen,

On 18/08/2019 06:58, Wenwen Wang wrote:
> 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.
We could also free it up in the error path, with an if (ret) kfree(ctx);
and remove the kfree which is in the "if (IS_ERR(ctx->fh.m2m_ctx))" check.

But I think that doesn't gain much really. So this is ok by me... If you
prefer that method, then feel free to submit a v2,

Otherwise I think this is fine:

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

> ---
>  drivers/media/platform/rcar_fdp1.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c
> index 43aae9b..9e4b330 100644
> --- a/drivers/media/platform/rcar_fdp1.c
> +++ b/drivers/media/platform/rcar_fdp1.c
> @@ -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;
>  	}
>  
> 


      reply	other threads:[~2019-08-21 11:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-18  5:58 [PATCH] media: fdp1: Fix a memory leak bug Wenwen Wang
2019-08-21 11:39 ` Kieran Bingham [this message]

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=5cb18e08-4e9b-6ca4-015a-fb21b4f7d504@ideasonboard.com \
    --to=kieran.bingham+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=wenwen@cs.uga.edu \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).