Message ID | 1553296835-37522-3-git-send-email-parav@mellanox.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vfio/mdev: Improve vfio/mdev core module | expand |
On Fri, 2019-03-22 at 18:20 -0500, Parav Pandit wrote: > During mdev parent registration in mdev_register_device(), > if parent device is duplicate, it releases the reference of existing > parent device. > This is incorrect. Existing parent device should not be touched. > > Fixes: 7b96953bc640 ("vfio: Mediated device Core driver") > Signed-off-by: Parav Pandit <parav@mellanox.com> > --- > drivers/vfio/mdev/mdev_core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c > index 3e5880a..4f213e4d 100644 > --- a/drivers/vfio/mdev/mdev_core.c > +++ b/drivers/vfio/mdev/mdev_core.c > @@ -182,6 +182,7 @@ int mdev_register_device(struct device *dev, const struct > mdev_parent_ops *ops) > /* Check for duplicate */ > parent = __find_parent_device(dev); > if (parent) { > + parent = NULL; > ret = -EEXIST; > goto add_dev_err; > } This is also clearly an issue. Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky
On 3/23/2019 4:50 AM, Parav Pandit wrote: > During mdev parent registration in mdev_register_device(), > if parent device is duplicate, it releases the reference of existing > parent device. > This is incorrect. Existing parent device should not be touched. > > Fixes: 7b96953bc640 ("vfio: Mediated device Core driver") > Signed-off-by: Parav Pandit <parav@mellanox.com> > --- > drivers/vfio/mdev/mdev_core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c > index 3e5880a..4f213e4d 100644 > --- a/drivers/vfio/mdev/mdev_core.c > +++ b/drivers/vfio/mdev/mdev_core.c > @@ -182,6 +182,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) > /* Check for duplicate */ > parent = __find_parent_device(dev); > if (parent) { > + parent = NULL; > ret = -EEXIST; > goto add_dev_err; > } > Agreed. Thanks for fixing this. Reviewed By: Kirti Wankhede <kwankhede@nvidia.com> Thanks, Kirti
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index 3e5880a..4f213e4d 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -182,6 +182,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) /* Check for duplicate */ parent = __find_parent_device(dev); if (parent) { + parent = NULL; ret = -EEXIST; goto add_dev_err; }
During mdev parent registration in mdev_register_device(), if parent device is duplicate, it releases the reference of existing parent device. This is incorrect. Existing parent device should not be touched. Fixes: 7b96953bc640 ("vfio: Mediated device Core driver") Signed-off-by: Parav Pandit <parav@mellanox.com> --- drivers/vfio/mdev/mdev_core.c | 1 + 1 file changed, 1 insertion(+)