Displaying 20 results from an estimated 158 matches for "module_put".
2019 Sep 26
2
[PATCH V2 5/8] mdev: introduce device specific ops
...nternal interface between
> modules. The user is interacting with filesystem objects from the vfio
> module and the module reference we're trying to acquire here is to the
> vfio-mdev module. Thanks,
>
> Alex
I think the latent bug refers not to module get per se,
but to the module_put tied to it. E.g.:
static void vfio_mdev_release(void *device_data)
{
struct mdev_device *mdev = device_data;
struct mdev_parent *parent = mdev->parent;
if (likely(parent->ops->release))
parent->ops->release(mdev);
module_put(THIS_M...
2019 Sep 26
2
[PATCH V2 5/8] mdev: introduce device specific ops
...nternal interface between
> modules. The user is interacting with filesystem objects from the vfio
> module and the module reference we're trying to acquire here is to the
> vfio-mdev module. Thanks,
>
> Alex
I think the latent bug refers not to module get per se,
but to the module_put tied to it. E.g.:
static void vfio_mdev_release(void *device_data)
{
struct mdev_device *mdev = device_data;
struct mdev_parent *parent = mdev->parent;
if (likely(parent->ops->release))
parent->ops->release(mdev);
module_put(THIS_M...
2019 Sep 26
0
[PATCH V2 5/8] mdev: introduce device specific ops
...he user is interacting with filesystem objects from the vfio
> > module and the module reference we're trying to acquire here is to the
> > vfio-mdev module. Thanks,
> >
> > Alex
>
>
> I think the latent bug refers not to module get per se,
> but to the module_put tied to it. E.g.:
>
> static void vfio_mdev_release(void *device_data)
> {
> struct mdev_device *mdev = device_data;
> struct mdev_parent *parent = mdev->parent;
>
> if (likely(parent->ops->release))
> parent->ops->r...
2019 Sep 19
3
[RFC v4 0/3] vhost: introduce mdev based hardware backend
...ioctl work.
I see. Thanks! IIUC, you mean we can provide a very tiny
VFIO device driver in drivers/vhost/mdev.c, e.g.:
static int vfio_vhost_mdev_open(void *device_data)
{
if (!try_module_get(THIS_MODULE))
return -ENODEV;
return 0;
}
static void vfio_vhost_mdev_release(void *device_data)
{
module_put(THIS_MODULE);
}
static const struct vfio_device_ops vfio_vhost_mdev_dev_ops = {
.name = "vfio-vhost-mdev",
.open = vfio_vhost_mdev_open,
.release = vfio_vhost_mdev_release,
};
static int vhost_mdev_probe(struct device *dev)
{
struct mdev_device *mdev = to_mdev_device(dev);
... C...
2019 Sep 19
3
[RFC v4 0/3] vhost: introduce mdev based hardware backend
...ioctl work.
I see. Thanks! IIUC, you mean we can provide a very tiny
VFIO device driver in drivers/vhost/mdev.c, e.g.:
static int vfio_vhost_mdev_open(void *device_data)
{
if (!try_module_get(THIS_MODULE))
return -ENODEV;
return 0;
}
static void vfio_vhost_mdev_release(void *device_data)
{
module_put(THIS_MODULE);
}
static const struct vfio_device_ops vfio_vhost_mdev_dev_ops = {
.name = "vfio-vhost-mdev",
.open = vfio_vhost_mdev_open,
.release = vfio_vhost_mdev_release,
};
static int vhost_mdev_probe(struct device *dev)
{
struct mdev_device *mdev = to_mdev_device(dev);
... C...
2020 Apr 14
0
[PATCH v2 07/33] iommu: Add probe_device() and remove_device() call-backs
...ops *ops = dev->bus->iommu_ops;
@@ -191,10 +221,17 @@ int iommu_probe_device(struct device *dev)
goto err_free_dev_param;
}
- ret = ops->add_device(dev);
+ if (ops->probe_device)
+ ret = __iommu_probe_device(dev);
+ else
+ ret = ops->add_device(dev);
+
if (ret)
goto err_module_put;
+ if (ops->probe_finalize)
+ ops->probe_finalize(dev);
+
return 0;
err_module_put:
@@ -204,17 +241,31 @@ int iommu_probe_device(struct device *dev)
return ret;
}
+static void __iommu_release_device(struct device *dev)
+{
+ const struct iommu_ops *ops = dev->bus->iommu_ops;...
2020 Apr 14
0
[PATCH v2 32/33] iommu: Remove add_device()/remove_device() code-paths
...f (!ops)
- return -EINVAL;
-
- if (!dev_iommu_get(dev))
- return -ENOMEM;
-
- if (!try_module_get(ops->owner)) {
- ret = -EINVAL;
- goto err_free_dev_param;
- }
-
- if (ops->probe_device)
- return __iommu_probe_device_helper(dev);
-
- ret = ops->add_device(dev);
- if (ret)
- goto err_module_put;
-
- group = iommu_group_get(dev);
- iommu_create_device_direct_mappings(group, dev);
- iommu_group_put(group);
-
- if (ops->probe_finalize)
- ops->probe_finalize(dev);
- return 0;
-
-err_module_put:
- module_put(ops->owner);
-err_free_dev_param:
- dev_iommu_free(dev);
- return ret;
-}...
2019 Sep 17
2
[RFC PATCH 2/2] mdev: introduce device specific ops
...int ret;
>
> - if (unlikely(!parent->ops->open))
> + if (unlikely(!ops->open))
> return -EINVAL;
>
> if (!try_module_get(THIS_MODULE))
> return -ENODEV;
>
> - ret = parent->ops->open(mdev);
> + ret = ops->open(mdev);
> if (ret)
> module_put(THIS_MODULE);
>
> @@ -44,9 +45,10 @@ static void vfio_mdev_release(void *device_data)
> {
> struct mdev_device *mdev = device_data;
> struct mdev_parent *parent = mdev->parent;
> + const struct vfio_mdev_parent_ops *ops = parent->ops-
> >device_ops;
>
> -...
2019 Sep 17
2
[RFC PATCH 2/2] mdev: introduce device specific ops
...int ret;
>
> - if (unlikely(!parent->ops->open))
> + if (unlikely(!ops->open))
> return -EINVAL;
>
> if (!try_module_get(THIS_MODULE))
> return -ENODEV;
>
> - ret = parent->ops->open(mdev);
> + ret = ops->open(mdev);
> if (ret)
> module_put(THIS_MODULE);
>
> @@ -44,9 +45,10 @@ static void vfio_mdev_release(void *device_data)
> {
> struct mdev_device *mdev = device_data;
> struct mdev_parent *parent = mdev->parent;
> + const struct vfio_mdev_parent_ops *ops = parent->ops-
> >device_ops;
>
> -...
2008 Sep 01
1
[PATCH 1/4 v2] PCI: introduce new base functions
...*slot, type *value) \
{ \
struct hotplug_slot_ops *ops = slot->ops; \
int retval = 0; \
- if (try_module_get(ops->owner)) { \
- if (ops->get_##name) \
- retval = ops->get_##name(slot, value); \
- else \
- *value = slot->info->name; \
- module_put(ops->owner); \
- } \
+ if (!try_module_get(ops->owner)) \
+ return -ENODEV; \
+ if (ops->get_##name) \
+ retval = ops->get_##name(slot, value); \
+ else \
+ *value = slot->info->name; \
+ module_put(ops->owner); \
return retval;...
2008 Sep 01
1
[PATCH 1/4 v2] PCI: introduce new base functions
...*slot, type *value) \
{ \
struct hotplug_slot_ops *ops = slot->ops; \
int retval = 0; \
- if (try_module_get(ops->owner)) { \
- if (ops->get_##name) \
- retval = ops->get_##name(slot, value); \
- else \
- *value = slot->info->name; \
- module_put(ops->owner); \
- } \
+ if (!try_module_get(ops->owner)) \
+ return -ENODEV; \
+ if (ops->get_##name) \
+ retval = ops->get_##name(slot, value); \
+ else \
+ *value = slot->info->name; \
+ module_put(ops->owner); \
return retval;...
2008 Sep 01
1
[PATCH 1/4 v2] PCI: introduce new base functions
...*slot, type *value) \
{ \
struct hotplug_slot_ops *ops = slot->ops; \
int retval = 0; \
- if (try_module_get(ops->owner)) { \
- if (ops->get_##name) \
- retval = ops->get_##name(slot, value); \
- else \
- *value = slot->info->name; \
- module_put(ops->owner); \
- } \
+ if (!try_module_get(ops->owner)) \
+ return -ENODEV; \
+ if (ops->get_##name) \
+ retval = ops->get_##name(slot, value); \
+ else \
+ *value = slot->info->name; \
+ module_put(ops->owner); \
return retval;...
2019 Sep 26
6
[PATCH] vhost: introduce mdev based hardware backend
...}
+
+ dev = &m->dev;
+ for (i = 0; i < nvqs; i++) {
+ vqs[i] = &m->vqs[i];
+ vqs[i]->handle_kick = handle_vq_kick;
+ }
+ vhost_dev_init(dev, vqs, nvqs, 0, 0, 0);
+ m->opened = true;
+ mutex_unlock(&m->mutex);
+
+ return 0;
+
+err:
+ mutex_unlock(&m->mutex);
+ module_put(THIS_MODULE);
+ return r;
+}
+
+static void vhost_mdev_release(void *device_data)
+{
+ struct vhost_mdev *m = device_data;
+
+ mutex_lock(&m->mutex);
+ vhost_mdev_reset(m);
+ vhost_dev_stop(&m->dev);
+ vhost_dev_cleanup(&m->dev);
+
+ kfree(m->dev.vqs);
+ m->opened = false...
2019 Sep 26
6
[PATCH] vhost: introduce mdev based hardware backend
...}
+
+ dev = &m->dev;
+ for (i = 0; i < nvqs; i++) {
+ vqs[i] = &m->vqs[i];
+ vqs[i]->handle_kick = handle_vq_kick;
+ }
+ vhost_dev_init(dev, vqs, nvqs, 0, 0, 0);
+ m->opened = true;
+ mutex_unlock(&m->mutex);
+
+ return 0;
+
+err:
+ mutex_unlock(&m->mutex);
+ module_put(THIS_MODULE);
+ return r;
+}
+
+static void vhost_mdev_release(void *device_data)
+{
+ struct vhost_mdev *m = device_data;
+
+ mutex_lock(&m->mutex);
+ vhost_mdev_reset(m);
+ vhost_dev_stop(&m->dev);
+ vhost_dev_cleanup(&m->dev);
+
+ kfree(m->dev.vqs);
+ m->opened = false...
2019 Sep 20
1
[RFC v4 0/3] vhost: introduce mdev based hardware backend
...v.c, e.g.:
> >
> > static int vfio_vhost_mdev_open(void *device_data)
> > {
> > if (!try_module_get(THIS_MODULE))
> > return -ENODEV;
> > return 0;
> > }
> >
> > static void vfio_vhost_mdev_release(void *device_data)
> > {
> > module_put(THIS_MODULE);
> > }
> >
> > static const struct vfio_device_ops vfio_vhost_mdev_dev_ops = {
> > .name = "vfio-vhost-mdev",
> > .open = vfio_vhost_mdev_open,
> > .release = vfio_vhost_mdev_release,
> > };
> >
> > static int vhost...
2019 Sep 25
3
[PATCH V2 5/8] mdev: introduce device specific ops
...r of uses of try_module_get(THIS_MODULE) in the kernel
source but most if not all of them are latent bugs that should be cleaned
up.
> >
> > > - ret = parent->ops->open(mdev);
> > > + ret = ops->open(mdev);
> > > if (ret)
> > > module_put(THIS_MODULE);
> > >
> > > @@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data)
> > > static void vfio_mdev_release(void *device_data)
> > > {
> > > struct mdev_device *mdev = device_data;
> > > - struct mdev_parent *parent =...
2019 Sep 25
3
[PATCH V2 5/8] mdev: introduce device specific ops
...r of uses of try_module_get(THIS_MODULE) in the kernel
source but most if not all of them are latent bugs that should be cleaned
up.
> >
> > > - ret = parent->ops->open(mdev);
> > > + ret = ops->open(mdev);
> > > if (ret)
> > > module_put(THIS_MODULE);
> > >
> > > @@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data)
> > > static void vfio_mdev_release(void *device_data)
> > > {
> > > struct mdev_device *mdev = device_data;
> > > - struct mdev_parent *parent =...
2019 Sep 17
2
[RFC v4 0/3] vhost: introduce mdev based hardware backend
...to include below vhost header. */
#include "../../vhost/vhost.h"
static int vfio_vhost_mdev_open(void *device_data)
{
if (!try_module_get(THIS_MODULE))
return -ENODEV;
/* ... */
vhost_dev_init(...);
return 0;
}
static void vfio_vhost_mdev_release(void *device_data)
{
/* ... */
module_put(THIS_MODULE);
}
static long vfio_vhost_mdev_unlocked_ioctl(void *device_data,
unsigned int cmd, unsigned long arg)
{
struct mdev_device *mdev = device_data;
struct mdev_parent *parent = mdev->parent;
/*
* Use vhost ioctls.
*
* We will have a different parent_ops design.
* An...
2019 Sep 17
2
[RFC v4 0/3] vhost: introduce mdev based hardware backend
...to include below vhost header. */
#include "../../vhost/vhost.h"
static int vfio_vhost_mdev_open(void *device_data)
{
if (!try_module_get(THIS_MODULE))
return -ENODEV;
/* ... */
vhost_dev_init(...);
return 0;
}
static void vfio_vhost_mdev_release(void *device_data)
{
/* ... */
module_put(THIS_MODULE);
}
static long vfio_vhost_mdev_unlocked_ioctl(void *device_data,
unsigned int cmd, unsigned long arg)
{
struct mdev_device *mdev = device_data;
struct mdev_parent *parent = mdev->parent;
/*
* Use vhost ioctls.
*
* We will have a different parent_ops design.
* An...
2019 Sep 26
0
[PATCH] vhost: introduce mdev based hardware backend
...{
> + vqs[i] = &m->vqs[i];
> + vqs[i]->handle_kick = handle_vq_kick;
> + }
> + vhost_dev_init(dev, vqs, nvqs, 0, 0, 0);
> + m->opened = true;
> + mutex_unlock(&m->mutex);
> +
> + return 0;
> +
> +err:
> + mutex_unlock(&m->mutex);
> + module_put(THIS_MODULE);
> + return r;
> +}
> +
> +static void vhost_mdev_release(void *device_data)
> +{
> + struct vhost_mdev *m = device_data;
> +
> + mutex_lock(&m->mutex);
> + vhost_mdev_reset(m);
> + vhost_dev_stop(&m->dev);
> + vhost_dev_cleanup(&m->...