From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/i915: bail in alloc_pdp when !FULL_48BIT_PPGTT
Date: Mon, 25 Apr 2016 18:04:27 +0300 [thread overview]
Message-ID: <1461596667.5848.14.camel@linux.intel.com> (raw)
In-Reply-To: <1461323137-21045-1-git-send-email-matthew.auld@intel.com>
On pe, 2016-04-22 at 12:05 +0100, Matthew Auld wrote:
> If we are not in FULL_48BIT_PPGTT mode then we really shouldn't
> continue on with our allocations, given that the call to free_pdp would
> bail early without freeing everything, thus leaking memory.
>
> v2:
> (Joonas Lahtinen)
> - tidy up with goto teardown path
>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem_gtt.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 0d666b3..f996f4b 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -567,13 +567,16 @@ static struct
> i915_page_directory_pointer *alloc_pdp(struct drm_device *dev)
> {
> struct i915_page_directory_pointer *pdp;
> - int ret = -ENOMEM;
> + int ret = -EINVAL;
>
> - WARN_ON(!USES_FULL_48BIT_PPGTT(dev));
> + if (WARN_ON(!USES_FULL_48BIT_PPGTT(dev)))
> + goto fail_pdp;
>
> pdp = kzalloc(sizeof(*pdp), GFP_KERNEL);
> - if (!pdp)
> - return ERR_PTR(-ENOMEM);
> + if (!pdp) {
> + ret = -ENOMEM;
> + goto fail_pdp;
> + }
>
> ret = __pdp_init(dev, pdp);
> if (ret)
> @@ -589,7 +592,7 @@ fail_page_m:
> __pdp_fini(pdp);
> fail_bitmap:
> kfree(pdp);
> -
> +fail_pdp:
According to the Kernel Coding Style Chapter 7: "Centralized exiting of
functions", the naming of this label should likely just be "fail:", as
it does not free anything. The label should describe what is done under
the label, not why the label is entered (which may vary as function
grows).
With that,
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Regards, Joonas
> return ERR_PTR(ret);
> }
>
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
prev parent reply other threads:[~2016-04-25 15:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 11:05 [PATCH 2/3] drm/i915: bail in alloc_pdp when !FULL_48BIT_PPGTT Matthew Auld
2016-04-25 15:04 ` Joonas Lahtinen [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=1461596667.5848.14.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthew.auld@intel.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 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.