From: Jason Gunthorpe <jgg@nvidia.com>
To: Yi Liu <yi.l.liu@intel.com>
Cc: alex.williamson@redhat.com, kevin.tian@intel.com,
joro@8bytes.org, robin.murphy@arm.com, cohuck@redhat.com,
eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org,
mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com,
yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com,
shameerali.kolothum.thodi@huawei.com, lulu@redhat.com,
suravee.suthikulpanit@amd.com,
intel-gvt-dev@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, linux-s390@vger.kernel.org,
xudong.hao@intel.com, yan.y.zhao@intel.com,
terrence.xu@intel.com
Subject: Re: [PATCH v2 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()
Date: Mon, 20 Mar 2023 14:34:28 -0300 [thread overview]
Message-ID: <ZBiZJDo+vD7uJTfP@nvidia.com> (raw)
In-Reply-To: <20230316121526.5644-2-yi.l.liu@intel.com>
On Thu, Mar 16, 2023 at 05:15:22AM -0700, Yi Liu wrote:
> +int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id)
> +{
> + struct iommufd_ioas *new_ioas;
> + struct iommufd_object *obj;
> + int rc = 0;
> +
> + if (access->ioas != NULL && access->ioas->obj.id != ioas_id)
> + return -EINVAL;
> +
> + obj = iommufd_get_object(access->ictx, ioas_id, IOMMUFD_OBJ_IOAS);
> + if (IS_ERR(obj))
> + return PTR_ERR(obj);
> + new_ioas = container_of(obj, struct iommufd_ioas, obj);
This is
iommufd_get_ioas()
> @@ -161,15 +170,20 @@ EXPORT_SYMBOL_GPL(vfio_iommufd_emulated_unbind);
>
> int vfio_iommufd_emulated_attach_ioas(struct vfio_device *vdev, u32 *pt_id)
> {
> - struct iommufd_access *user;
> + int rc;
>
> lockdep_assert_held(&vdev->dev_set->lock);
>
> - user = iommufd_access_create(vdev->iommufd_ictx, *pt_id, &vfio_user_ops,
> - vdev);
> - if (IS_ERR(user))
> - return PTR_ERR(user);
> - vdev->iommufd_access = user;
> + if (WARN_ON(!vdev->iommufd_ictx))
> + return -EINVAL;
If you are going to delete these lines in the next patch don't add
them here.
> + if (WARN_ON(!vdev->iommufd_access))
> + return -ENOENT;
Just let it NULL pointer deref crash on this impossible case.
Looks OK otherwise
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
next prev parent reply other threads:[~2023-03-20 17:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 12:15 [PATCH v2 0/5] vfio: Make emulated devices prepared for vfio device cdev Yi Liu
2023-03-16 12:15 ` [PATCH v2 1/5] iommufd: Create access in vfio_iommufd_emulated_bind() Yi Liu
2023-03-20 17:34 ` Jason Gunthorpe [this message]
2023-03-16 12:15 ` [PATCH v2 2/5] vfio-iommufd: No need to record iommufd_ctx in vfio_device Yi Liu
2023-03-17 1:05 ` Tian, Kevin
2023-03-16 12:15 ` [PATCH v2 3/5] vfio-iommufd: Make vfio_iommufd_emulated_bind() return iommufd_access ID Yi Liu
2023-03-16 12:15 ` [PATCH v2 4/5] vfio/mdev: Uses the vfio emulated iommufd ops set in the mdev sample drivers Yi Liu
2023-03-17 1:05 ` Tian, Kevin
2023-03-16 12:15 ` [PATCH v2 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev() Yi Liu
2023-03-17 1:06 ` Tian, Kevin
2023-03-17 8:43 ` [PATCH v2 0/5] vfio: Make emulated devices prepared for vfio device cdev Xu, Terrence
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=ZBiZJDo+vD7uJTfP@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jasowang@redhat.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=terrence.xu@intel.com \
--cc=xudong.hao@intel.com \
--cc=yan.y.zhao@intel.com \
--cc=yi.l.liu@intel.com \
--cc=yi.y.sun@linux.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;
as well as URLs for NNTP newsgroup(s).