From: Matthew Brost <matthew.brost@intel.com>
To: "Lin, Shuicheng" <shuicheng.lin@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 4/4] drm/xe: Fix dma-buf attachment leak in xe_gem_prime_import()
Date: Wed, 8 Apr 2026 10:38:08 -0700 [thread overview]
Message-ID: <adaSgCBmcCIx2TWn@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <DM4PR11MB5456628E393BC1D7A9BFA59CEA5B2@DM4PR11MB5456.namprd11.prod.outlook.com>
On Wed, Apr 08, 2026 at 11:34:28AM -0600, Lin, Shuicheng wrote:
> On Tue, Apr 7, 2026 10:05 PM Matthew Brost wrote:
> > On Tue, Apr 07, 2026 at 08:15:42PM +0000, Shuicheng Lin wrote:
> > > When xe_dma_buf_init_obj() fails, the attachment from
> > > dma_buf_dynamic_attach() is not detached. Add dma_buf_detach() before
> > > returning the error. Note: we cannot use goto out_err here because
> > > xe_dma_buf_init_obj() already frees bo on failure, and out_err would
> > > double-free it.
> > >
> > > Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel
> > > GPUs")
> > > Cc: stable@vger.kernel.org
> > > Assisted-by: Claude:claude-opus-4.6
> > > Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
> > > ---
> > > drivers/gpu/drm/xe/xe_dma_buf.c | 11 +++++++----
> > > 1 file changed, 7 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c
> > > b/drivers/gpu/drm/xe/xe_dma_buf.c index 24d9d82426b9..7702a6bdaae5
> > > 100644
> > > --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> > > +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
> > > @@ -370,12 +370,15 @@ struct drm_gem_object
> > *xe_gem_prime_import(struct drm_device *dev,
> > > goto out_err;
> > > }
> > >
> > > - /* Errors here will take care of freeing the bo. */
> > > + /*
> > > + * xe_dma_buf_init_obj() takes ownership of bo on both success
> > > + * and failure, so we must not touch bo after this call.
> > > + */
> > > obj = xe_dma_buf_init_obj(dev, bo, dma_buf);
> > > - if (IS_ERR(obj))
> > > + if (IS_ERR(obj)) {
> > > + dma_buf_detach(dma_buf, attach);
> >
> > Based on my feedback from the previous patch [1], I think we also want...
> >
> > xe_bo_free(bo);
> >
> > Also unseen in this diff is this code:
> >
> > 365 attach = dma_buf_dynamic_attach(dma_buf, dev->dev, attach_ops,
> > &bo->ttm.base);
> > 366 if (IS_ERR(attach)) {
> > 367 obj = ERR_CAST(attach);
> > 368 goto out_err;
> > 369 }
> >
> > We also need a xe_bo_free(bo) in this failures if statement.
> >
> > Matt
^^^ Ignore all of this. Missed out_err calls xe_bo_free too.
So patch LGTM:
Reviewed-by: Mattheq Brost <matthew.brost@intel.com>
> >
> > [1]
> > https://patchwork.freedesktop.org/patch/716820/?series=164476&rev=1#c
> > omment_1319810
> >
>
> As discussed in another email, could you please help me review this patch again?
> Thanks.
>
> Shuicheng
>
> > > return obj;
> > > -
> > > -
> > > + }
> > > get_dma_buf(dma_buf);
> > > obj->import_attach = attach;
> > > return obj;
> > > --
> > > 2.43.0
> > >
next prev parent reply other threads:[~2026-04-08 17:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 20:15 [PATCH 0/4] drm/xe: Fix resource leaks in bo init and dma-buf paths Shuicheng Lin
2026-04-07 20:15 ` [PATCH 1/4] drm/xe/bo: Fix bo leak on unaligned size validation in xe_bo_init_locked() Shuicheng Lin
2026-04-08 4:52 ` Matthew Brost
2026-04-07 20:15 ` [PATCH 2/4] drm/xe/bo: Fix bo leak on GGTT flag " Shuicheng Lin
2026-04-08 4:54 ` Matthew Brost
2026-04-07 20:15 ` [PATCH 3/4] drm/xe: Fix bo leak in xe_dma_buf_init_obj() on allocation failure Shuicheng Lin
2026-04-08 5:01 ` Matthew Brost
2026-04-08 15:58 ` Lin, Shuicheng
2026-04-08 16:41 ` Matthew Brost
2026-04-07 20:15 ` [PATCH 4/4] drm/xe: Fix dma-buf attachment leak in xe_gem_prime_import() Shuicheng Lin
2026-04-08 5:04 ` Matthew Brost
2026-04-08 17:34 ` Lin, Shuicheng
2026-04-08 17:38 ` Matthew Brost [this message]
2026-04-07 21:48 ` ✗ CI.checkpatch: warning for drm/xe: Fix resource leaks in bo init and dma-buf paths Patchwork
2026-04-07 21:50 ` ✗ CI.KUnit: 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=adaSgCBmcCIx2TWn@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=shuicheng.lin@intel.com \
--cc=stable@vger.kernel.org \
/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.