From: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
To: Navid Emamdoost <navid.emamdoost@gmail.com>
Cc: linux-aspeed@lists.ozlabs.org, Andrew Jeffery <andrew@aj.id.au>,
kjlu@umn.edu, openbmc@lists.ozlabs.org,
Eddie James <eajames@linux.ibm.com>,
linux-kernel@vger.kernel.org, emamd001@umn.edu, smccaman@umn.edu,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-media@vger.kernel.org
Subject: Re: [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe
Date: Mon, 28 Oct 2019 09:27:30 -0700 [thread overview]
Message-ID: <d9c04318-586a-bfc2-fce6-6218c6bab1d6@linux.intel.com> (raw)
In-Reply-To: <20191026042519.29446-1-navid.emamdoost@gmail.com>
Hi Navid,
On 10/25/2019 9:25 PM, Navid Emamdoost wrote:
> In the implementation of aspeed_video_probe() the allocated memory for
> video should be released in case of failure. Release video if either
> devm_ioremap_resource() or aspeed_video_init() or
> aspeed_video_setup_video() fails.
>
> Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> drivers/media/platform/aspeed-video.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> index eb12f3793062..8c473356132d 100644
> --- a/drivers/media/platform/aspeed-video.c
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -1663,18 +1663,24 @@ static int aspeed_video_probe(struct platform_device *pdev)
>
> video->base = devm_ioremap_resource(video->dev, res);
>
> - if (IS_ERR(video->base))
> - return PTR_ERR(video->base);
> + if (IS_ERR(video->base)) {
> + rc = PTR_ERR(video->base);
> + goto free_video;
> + }
>
> rc = aspeed_video_init(video);
> if (rc)
> - return rc;
> + goto free_video;
>
> rc = aspeed_video_setup_video(video);
> if (rc)
> - return rc;
> + goto free_video;
>
> return 0;
> +
> +free_video:
> + kfree(video);
> + return rc;
> }
>
> static int aspeed_video_remove(struct platform_device *pdev)
>
Can we simply change kzalloc in aspeed_video_probe with devm_kzalloc
so that we don't need to take care of freeing of video? I think it would
be more simpler.
Cheers,
Jae
_______________________________________________
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:[~2019-10-28 16:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-26 4:25 [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe Navid Emamdoost
2019-10-27 6:55 ` Markus Elfring
2019-10-28 16:27 ` Jae Hyun Yoo [this message]
2019-10-28 16:30 ` Navid Emamdoost
2019-10-28 16:58 ` [PATCH v2] " Navid Emamdoost
2019-10-28 17:01 ` Jae Hyun Yoo
2019-10-28 17:06 ` Navid Emamdoost
2019-10-28 17:08 ` Jae Hyun Yoo
2019-10-28 17:18 ` [PATCH v3] " Navid Emamdoost
2019-10-28 17:55 ` Jae Hyun Yoo
2019-11-08 20:37 ` Eddie James
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=d9c04318-586a-bfc2-fce6-6218c6bab1d6@linux.intel.com \
--to=jae.hyun.yoo@linux.intel.com \
--cc=andrew@aj.id.au \
--cc=eajames@linux.ibm.com \
--cc=emamd001@umn.edu \
--cc=kjlu@umn.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=navid.emamdoost@gmail.com \
--cc=openbmc@lists.ozlabs.org \
--cc=smccaman@umn.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).