From: Jason Gunthorpe <jgg@nvidia.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Alex Williamson <alex.williamson@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
kvm@vger.kernel.org, "Tian, Kevin" <kevin.tian@intel.com>,
Liu Yi L <yi.l.liu@intel.com>
Subject: Re: [PATCH v2 3/5] vfio: Don't leak a group reference if the group already exists
Date: Wed, 13 Oct 2021 13:18:36 -0300 [thread overview]
Message-ID: <20211013161836.GH2744544@nvidia.com> (raw)
In-Reply-To: <20211013160910.GC1327@lst.de>
On Wed, Oct 13, 2021 at 06:09:10PM +0200, Christoph Hellwig wrote:
> > @@ -775,12 +776,7 @@ static struct vfio_group *vfio_group_find_or_alloc(struct device *dev)
> > if (group)
> > goto out_put;
> >
> > - /* a newly created vfio_group keeps the reference. */
> > group = vfio_create_group(iommu_group, VFIO_IOMMU);
> > - if (IS_ERR(group))
> > - goto out_put;
> > - return group;
> > -
> > out_put:
> > iommu_group_put(iommu_group);
> > return group;
>
> I'd simplify this down to:
>
> group = vfio_group_get_from_iommu(iommu_group);
> if (!group)
> group = vfio_create_group(iommu_group, VFIO_IOMMU);
Yes, OK, I changed it into this:
group = vfio_group_get_from_iommu(iommu_group);
if (!group)
group = vfio_create_group(iommu_group, VFIO_IOMMU);
/* The vfio_group holds a reference to the iommu_group */
iommu_group_put(iommu_group);
return group;
}
Which I think is clearer on the comment too
Thanks,
Jason
next prev parent reply other threads:[~2021-10-13 16:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 14:27 [PATCH v2 0/5] Update vfio_group to use the modern cdev lifecycle Jason Gunthorpe
2021-10-13 14:27 ` [PATCH v2 1/5] vfio: Delete vfio_get/put_group from vfio_iommu_group_notifier() Jason Gunthorpe
2021-10-13 16:04 ` Christoph Hellwig
2021-10-13 14:27 ` [PATCH v2 2/5] vfio: Do not open code the group list search in vfio_create_group() Jason Gunthorpe
2021-10-13 16:05 ` Christoph Hellwig
2021-10-13 14:27 ` [PATCH v2 3/5] vfio: Don't leak a group reference if the group already exists Jason Gunthorpe
2021-10-13 16:09 ` Christoph Hellwig
2021-10-13 16:18 ` Jason Gunthorpe [this message]
2021-10-14 2:08 ` Tian, Kevin
2021-10-13 14:27 ` [PATCH v2 4/5] vfio: Use a refcount_t instead of a kref in the vfio_group Jason Gunthorpe
2021-10-13 16:10 ` Christoph Hellwig
2021-10-13 14:27 ` [PATCH v2 5/5] vfio: Use cdev_device_add() instead of device_create() Jason Gunthorpe
2021-10-13 17:08 ` Christoph Hellwig
2021-10-13 17:42 ` Jason Gunthorpe
2021-10-14 21:04 ` Alex Williamson
2021-10-14 2:09 ` Tian, Kevin
2021-10-15 6:03 ` [PATCH v2 0/5] Update vfio_group to use the modern cdev lifecycle Liu, Yi L
2021-10-15 11:41 ` Jason Gunthorpe
2021-10-15 11:43 ` Liu, Yi L
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=20211013161836.GH2744544@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=hch@lst.de \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=yi.l.liu@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