From: Matthew Auld <matthew.auld@intel.com>
To: Nirmoy Das <nirmoy.das@intel.com>, intel-xe@lists.freedesktop.org
Cc: Matthew Brost <matthew.brost@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Stuart Summers <stuart.summers@intel.com>
Subject: Re: [PATCH] drm/xe: Fix memory leak on xe_alloc_pf_queue failure
Date: Thu, 22 Aug 2024 09:52:35 +0100 [thread overview]
Message-ID: <a7bcbf49-75d2-4b9c-b49f-11f6d348a7ab@intel.com> (raw)
In-Reply-To: <20240822081325.1549-1-nirmoy.das@intel.com>
On 22/08/2024 09:13, Nirmoy Das wrote:
> Free up previously allocated pf_queue[i].data on error.
>
> Fixes: 3338e4f90c14 ("drm/xe: Use topology to determine page fault queue size")
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Stuart Summers <stuart.summers@intel.com>
> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt_pagefault.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.c b/drivers/gpu/drm/xe/xe_gt_pagefault.c
> index 0be4687bfc20..c19944eed5bd 100644
> --- a/drivers/gpu/drm/xe/xe_gt_pagefault.c
> +++ b/drivers/gpu/drm/xe/xe_gt_pagefault.c
> @@ -437,9 +437,13 @@ int xe_gt_pagefault_init(struct xe_gt *gt)
>
> for (i = 0; i < NUM_PF_QUEUE; ++i) {
> ret = xe_alloc_pf_queue(gt, >->usm.pf_queue[i]);
> - if (ret)
> + if (ret) {
> + while (i-- > 0)
> + kfree(gt->usm.pf_queue[i].data);
> return ret;
> + }
> }
I think this will then also leak below, if one of the queue create
fails? Maybe just convert this over to devm_calloc or similar that way
we don't need to do the manual unwind.
> +
> for (i = 0; i < NUM_ACC_QUEUE; ++i) {
> gt->usm.acc_queue[i].gt = gt;
> spin_lock_init(>->usm.acc_queue[i].lock);
next prev parent reply other threads:[~2024-08-22 8:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 8:13 [PATCH] drm/xe: Fix memory leak on xe_alloc_pf_queue failure Nirmoy Das
2024-08-22 8:52 ` Matthew Auld [this message]
2024-08-22 9:10 ` Nirmoy Das
2024-08-22 8:52 ` ✓ CI.Patch_applied: success for " Patchwork
2024-08-22 8:53 ` ✓ CI.checkpatch: " Patchwork
2024-08-22 8:54 ` ✓ CI.KUnit: " Patchwork
2024-08-22 9:06 ` ✓ CI.Build: " Patchwork
2024-08-22 9:08 ` ✓ CI.Hooks: " Patchwork
2024-08-22 9:11 ` ✓ CI.checksparse: " Patchwork
2024-08-22 9:30 ` ✓ CI.BAT: " Patchwork
2024-08-22 12:52 ` ✗ CI.FULL: failure " Patchwork
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=a7bcbf49-75d2-4b9c-b49f-11f6d348a7ab@intel.com \
--to=matthew.auld@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=nirmoy.das@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=stuart.summers@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox