diff mbox series

[RFC,v3,10/11] vduse: grab the module's references until there is no vduse device

Message ID 20210119050756.600-4-xieyongji@bytedance.com (mailing list archive)
State New, archived
Headers show
Series Introduce VDUSE - vDPA Device in Userspace | expand

Commit Message

Yongji Xie Jan. 19, 2021, 5:07 a.m. UTC
The module should not be unloaded if any vduse device exists.
So increase the module's reference count when creating vduse
device. And the reference count is kept until the device is
destroyed.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
---
 drivers/vdpa/vdpa_user/vduse_dev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jason Wang Jan. 26, 2021, 8:09 a.m. UTC | #1
On 2021/1/19 下午1:07, Xie Yongji wrote:
> The module should not be unloaded if any vduse device exists.
> So increase the module's reference count when creating vduse
> device. And the reference count is kept until the device is
> destroyed.
>
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>


Looks like a bug fix. If yes, let's squash this into patch 8.

Thanks


> ---
>   drivers/vdpa/vdpa_user/vduse_dev.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
> index 4d21203da5b6..003aeb281bce 100644
> --- a/drivers/vdpa/vdpa_user/vduse_dev.c
> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
> @@ -978,6 +978,7 @@ static int vduse_destroy_dev(u32 id)
>   	kfree(dev->vqs);
>   	vduse_domain_destroy(dev->domain);
>   	vduse_dev_destroy(dev);
> +	module_put(THIS_MODULE);
>   
>   	return 0;
>   }
> @@ -1022,6 +1023,7 @@ static int vduse_create_dev(struct vduse_dev_config *config)
>   
>   	dev->connected = true;
>   	list_add(&dev->list, &vduse_devs);
> +	__module_get(THIS_MODULE);
>   
>   	return fd;
>   err_fd:
Yongji Xie Jan. 27, 2021, 8:51 a.m. UTC | #2
On Tue, Jan 26, 2021 at 4:10 PM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2021/1/19 下午1:07, Xie Yongji wrote:
> > The module should not be unloaded if any vduse device exists.
> > So increase the module's reference count when creating vduse
> > device. And the reference count is kept until the device is
> > destroyed.
> >
> > Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
>
>
> Looks like a bug fix. If yes, let's squash this into patch 8.
>

Will do it.

Thanks,
Yongji
diff mbox series

Patch

diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 4d21203da5b6..003aeb281bce 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -978,6 +978,7 @@  static int vduse_destroy_dev(u32 id)
 	kfree(dev->vqs);
 	vduse_domain_destroy(dev->domain);
 	vduse_dev_destroy(dev);
+	module_put(THIS_MODULE);
 
 	return 0;
 }
@@ -1022,6 +1023,7 @@  static int vduse_create_dev(struct vduse_dev_config *config)
 
 	dev->connected = true;
 	list_add(&dev->list, &vduse_devs);
+	__module_get(THIS_MODULE);
 
 	return fd;
 err_fd: