All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Felix Kuehling <felix.kuehling@amd.com>
Cc: amd-gfx@lists.freedesktop.org,
	Maling list - DRI developers <dri-devel@lists.freedesktop.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/2][RFC] amdgpu: fix a race in kfd_mem_export_dmabuf()
Date: Tue, 4 Jun 2024 20:10:04 +0100	[thread overview]
Message-ID: <20240604191004.GR1629371@ZenIV> (raw)
In-Reply-To: <611b4f6e-e91b-4759-a170-fb43819000ce@amd.com>

On Tue, Jun 04, 2024 at 02:08:30PM -0400, Felix Kuehling wrote:
> > +int drm_gem_prime_handle_to_fd(struct drm_device *dev,
> > +			       struct drm_file *file_priv, uint32_t handle,
> > +			       uint32_t flags,
> > +			       int *prime_fd)
> > +{
> > +	struct dma_buf *dmabuf;
> > +	int fd = get_unused_fd_flags(flags);
> > +
> > +	if (fd < 0)
> > +		return fd;
> > +
> > +	dmabuf = drm_gem_prime_handle_to_dmabuf(dev, file_priv, handle, flags);
> > +	if (IS_ERR(dmabuf))
> > +		return PTR_ERR(dmabuf);

That ought to be
	if (IS_ERR(dmabuf)) {
		put_unused_fd(fd);
		return PTR_ERR(dmabuf);
	}
or we'll leak an allocated descriptor.  Will fix and repost...

  reply	other threads:[~2024-06-05 12:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  2:12 [PATCHES][RFC][CFT] close_fd() misuses in amdgpu Al Viro
2024-06-04  2:13 ` [PATCH 1/2][RFC] amdgpu: fix a race in kfd_mem_export_dmabuf() Al Viro
2024-06-04 18:08   ` Felix Kuehling
2024-06-04 19:10     ` Al Viro [this message]
2024-06-04 19:17       ` [PATCH v2 " Al Viro
2024-06-05  9:14     ` [PATCH " Christian König
2024-06-06 21:57       ` Felix Kuehling
2024-06-04  2:14 ` [PATCH 2/2][RFC] amdkfd CRIU fixes Al Viro
2024-06-04 18:16   ` Felix Kuehling
2024-06-04 19:20     ` Al Viro

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=20240604191004.GR1629371@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=linux-fsdevel@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.