From: Harry Wentland <harry.wentland@amd.com>
To: "Colin King" <colin.king@canonical.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@linux.ie>,
"Tony Cheng" <tony.cheng@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amd/display: fix memory leaks on error exit return
Date: Wed, 22 Nov 2017 12:13:35 -0500 [thread overview]
Message-ID: <7f0ece54-283a-aab6-da42-9102565e8e7e@amd.com> (raw)
In-Reply-To: <20171122164735.1497-1-colin.king@canonical.com>
On 2017-11-22 11:47 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently in the case where some of the allocations fail for dce110_tgv,
> dce110_xfmv, dce110_miv or dce110_oppv then the exit return path ends
> up leaking allocated objects. Fix this by kfree'ing them before returning.
> Also re-work the comparison of the null pointers to use the !ptr idiom.
>
> Detected by CoverityScan, CID#1460246, 1460325, 1460324, 1460392
> ("Resource Leak")
>
> Fixes: c4562236b3bc ("drm/amd/dc: Add dc display driver (v2)")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thanks. I got the same patch but was too slow to post.
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Harry
> ---
> drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> index db96d2b47ff1..61adb8174ce0 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
> @@ -1037,11 +1037,13 @@ static bool underlay_create(struct dc_context *ctx, struct resource_pool *pool)
> struct dce110_opp *dce110_oppv = kzalloc(sizeof(*dce110_oppv),
> GFP_KERNEL);
>
> - if ((dce110_tgv == NULL) ||
> - (dce110_xfmv == NULL) ||
> - (dce110_miv == NULL) ||
> - (dce110_oppv == NULL))
> - return false;
> + if (!dce110_tgv || !dce110_xfmv || !dce110_miv || !dce110_oppv) {
> + kfree(dce110_tgv);
> + kfree(dce110_xfmv);
> + kfree(dce110_miv);
> + kfree(dce110_oppv);
> + return false;
> + }
>
> dce110_opp_v_construct(dce110_oppv, ctx);
>
>
prev parent reply other threads:[~2017-11-22 17:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 16:47 Colin King
2017-11-22 17:13 ` Harry Wentland [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=7f0ece54-283a-aab6-da42-9102565e8e7e@amd.com \
--to=harry.wentland@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=colin.king@canonical.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.cheng@amd.com \
/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
all inboxes | Powered by JetHome®