* [PATCH v2 1/1] vfio: check vfio_register_iommu_driver() return value
@ 2022-06-22 4:56 Bo Liu
2022-06-23 13:26 ` Cornelia Huck
2022-06-30 19:51 ` Alex Williamson
0 siblings, 2 replies; 3+ messages in thread
From: Bo Liu @ 2022-06-22 4:56 UTC (permalink / raw)
To: alex.williamson, cohuck; +Cc: kvm, linux-kernel, Bo Liu
As vfio_register_iommu_driver() can fail, we should check the return value.
Signed-off-by: Bo Liu <liubo03@inspur.com>
---
Changes from v1:
-move the pr_info()
-move #endif above the ret test
-remove #ifdefs above the err_driver_register
drivers/vfio/vfio.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 61e71c1154be..8f435c0d7748 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -2156,13 +2156,17 @@ static int __init vfio_init(void)
if (ret)
goto err_alloc_chrdev;
- pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
-
#ifdef CONFIG_VFIO_NOIOMMU
- vfio_register_iommu_driver(&vfio_noiommu_ops);
+ ret = vfio_register_iommu_driver(&vfio_noiommu_ops);
#endif
+ if (ret)
+ goto err_driver_register;
+
+ pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
return 0;
+err_driver_register:
+ unregister_chrdev_region(vfio.group_devt, MINORMASK + 1);
err_alloc_chrdev:
class_destroy(vfio.class);
vfio.class = NULL;
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] vfio: check vfio_register_iommu_driver() return value
2022-06-22 4:56 [PATCH v2 1/1] vfio: check vfio_register_iommu_driver() return value Bo Liu
@ 2022-06-23 13:26 ` Cornelia Huck
2022-06-30 19:51 ` Alex Williamson
1 sibling, 0 replies; 3+ messages in thread
From: Cornelia Huck @ 2022-06-23 13:26 UTC (permalink / raw)
To: Bo Liu, alex.williamson; +Cc: kvm, linux-kernel, Bo Liu
On Wed, Jun 22 2022, Bo Liu <liubo03@inspur.com> wrote:
> As vfio_register_iommu_driver() can fail, we should check the return value.
>
> Signed-off-by: Bo Liu <liubo03@inspur.com>
> ---
> Changes from v1:
> -move the pr_info()
> -move #endif above the ret test
> -remove #ifdefs above the err_driver_register
>
> drivers/vfio/vfio.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Acked-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] vfio: check vfio_register_iommu_driver() return value
2022-06-22 4:56 [PATCH v2 1/1] vfio: check vfio_register_iommu_driver() return value Bo Liu
2022-06-23 13:26 ` Cornelia Huck
@ 2022-06-30 19:51 ` Alex Williamson
1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2022-06-30 19:51 UTC (permalink / raw)
To: Bo Liu; +Cc: cohuck, kvm, linux-kernel
On Wed, 22 Jun 2022 00:56:51 -0400
Bo Liu <liubo03@inspur.com> wrote:
> As vfio_register_iommu_driver() can fail, we should check the return value.
>
> Signed-off-by: Bo Liu <liubo03@inspur.com>
> ---
> Changes from v1:
> -move the pr_info()
> -move #endif above the ret test
> -remove #ifdefs above the err_driver_register
>
> drivers/vfio/vfio.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Applied to vfio next branch for v5.20. Thanks,
Alex
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 61e71c1154be..8f435c0d7748 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -2156,13 +2156,17 @@ static int __init vfio_init(void)
> if (ret)
> goto err_alloc_chrdev;
>
> - pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
> -
> #ifdef CONFIG_VFIO_NOIOMMU
> - vfio_register_iommu_driver(&vfio_noiommu_ops);
> + ret = vfio_register_iommu_driver(&vfio_noiommu_ops);
> #endif
> + if (ret)
> + goto err_driver_register;
> +
> + pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
> return 0;
>
> +err_driver_register:
> + unregister_chrdev_region(vfio.group_devt, MINORMASK + 1);
> err_alloc_chrdev:
> class_destroy(vfio.class);
> vfio.class = NULL;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-30 19:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 4:56 [PATCH v2 1/1] vfio: check vfio_register_iommu_driver() return value Bo Liu
2022-06-23 13:26 ` Cornelia Huck
2022-06-30 19:51 ` Alex Williamson
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).