diff mbox series

[-next] 9p/xen: Add cleanup path in p9_trans_xen_init

Message ID 20190430143933.19368-1-yuehaibing@huawei.com
State Not Applicable
Delegated to: David Miller
Headers show
Series [-next] 9p/xen: Add cleanup path in p9_trans_xen_init | expand

Commit Message

Yue Haibing April 30, 2019, 2:39 p.m. UTC
If xenbus_register_frontend() fails in p9_trans_xen_init,
we should call v9fs_unregister_trans() to do cleanup.

Fixes: 868eb122739a ("xen/9pfs: introduce Xen 9pfs transport driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 net/9p/trans_xen.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Dominique Martinet May 15, 2019, 3:41 p.m. UTC | #1
YueHaibing wrote on Tue, Apr 30, 2019:
> If xenbus_register_frontend() fails in p9_trans_xen_init,
> we should call v9fs_unregister_trans() to do cleanup.
> 
> Fixes: 868eb122739a ("xen/9pfs: introduce Xen 9pfs transport driver")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Thanks, queued both in my repo - sorry for the delay.
diff mbox series

Patch

diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 29420eb..3963eb1 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -530,13 +530,19 @@  static struct xenbus_driver xen_9pfs_front_driver = {
 
 static int p9_trans_xen_init(void)
 {
+	int rc;
+
 	if (!xen_domain())
 		return -ENODEV;
 
 	pr_info("Initialising Xen transport for 9pfs\n");
 
 	v9fs_register_trans(&p9_xen_trans);
-	return xenbus_register_frontend(&xen_9pfs_front_driver);
+	rc = xenbus_register_frontend(&xen_9pfs_front_driver);
+	if (rc)
+		v9fs_unregister_trans(&p9_xen_trans);
+
+	return rc;
 }
 module_init(p9_trans_xen_init);