Re: [PATCH RFC v2 06/15] vfio: ccw: register vfio_ccw to the mediated device framework

Dong Jia Shi
2017-01-18T02:28:58Z

* Alex Williamson <alex.williamson@redhat.com> [2017-01-17 14:02:33 -0700]:

[...]

> > diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
[...]

> > +static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev)
> > +{
> > + struct vfio_ccw_private *private = dev_get_drvdata(mdev->parent->dev);
> > +
> > + /* Only support one mediated device for each physical subchannel. */
> > + if (private->mdev)
> > + return -EPERM;
> > +
> > + private->mdev = mdev;
> > + available_instances--;
>
>
> This looks racy and doesn't enforce the available instances. Should
> this maybe be an atomic_t and use atomic_dec_if_positive() to return an
> error if no instances are available?
Hi Alex,

You are right. I will fix this according to your comment.

>
>
> > +
> > + return 0;
> > +}
> > +

[...]

--
Dong Jia