mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vfio: check vfio_register_iommu_driver() return value
@ 2022-06-21  6:21 Bo Liu
  2022-06-21 17:32 ` Alex Williamson
  0 siblings, 1 reply; 2+ messages in thread
From: Bo Liu @ 2022-06-21  6:21 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>
---
 drivers/vfio/vfio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 61e71c1154be..7d4b6dfafd27 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -2159,10 +2159,16 @@ static int __init vfio_init(void)
 	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);
+	if (ret)
+		goto err_driver_register;
 #endif
 	return 0;
 
+#ifdef CONFIG_VFIO_NOIOMMU
+err_driver_register:
+	unregister_chrdev_region(vfio.group_devt, MINORMASK + 1);
+#endif
 err_alloc_chrdev:
 	class_destroy(vfio.class);
 	vfio.class = NULL;
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-21 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21  6:21 [PATCH] vfio: check vfio_register_iommu_driver() return value Bo Liu
2022-06-21 17:32 ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®