diff options
author | Bo Liu <[email protected]> | 2022-06-22 00:56:51 -0400 |
---|---|---|
committer | Alex Williamson <[email protected]> | 2022-06-27 13:57:08 -0600 |
commit | a13b1e472b93f69c35976351e59831564ed6a376 (patch) | |
tree | 0756d3f22daf455cec9214cae4df92e05ae064b5 | |
parent | d1877e639bc6bf1c3131eda3f9ede73f8da96c22 (diff) |
vfio: check vfio_register_iommu_driver() return value
As vfio_register_iommu_driver() can fail, we should check the return value.
Signed-off-by: Bo Liu <[email protected]>
Acked-by: Cornelia Huck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alex Williamson <[email protected]>
-rw-r--r-- | drivers/vfio/vfio.c | 10 |
1 files 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; |