Skip to content

Commit 23bbbf5

Browse files
committed
Merge tag '9p-for-5.3' of git://github.com/martinetd/linux
Pull 9p updates from Dominique Martinet: "Two small fixes to properly cleanup the 9p transports list if virtio/xen module initialization fail. 9p might otherwise try to access memory from a module that failed to register got freed" * tag '9p-for-5.3' of git://github.com/martinetd/linux: 9p/xen: Add cleanup path in p9_trans_xen_init 9p/virtio: Add cleanup path in p9_virtio_init
2 parents a641a88 + 80a316f commit 23bbbf5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎net/9p/trans_virtio.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,16 @@ static struct p9_trans_module p9_virtio_trans = {
767767
/* The standard init function */
768768
static int __init p9_virtio_init(void)
769769
{
770+
int rc;
771+
770772
INIT_LIST_HEAD(&virtio_chan_list);
771773

772774
v9fs_register_trans(&p9_virtio_trans);
773-
return register_virtio_driver(&p9_virtio_drv);
775+
rc = register_virtio_driver(&p9_virtio_drv);
776+
if (rc)
777+
v9fs_unregister_trans(&p9_virtio_trans);
778+
779+
return rc;
774780
}
775781

776782
static void __exit p9_virtio_cleanup(void)

‎net/9p/trans_xen.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,19 @@ static struct xenbus_driver xen_9pfs_front_driver = {
530530

531531
static int p9_trans_xen_init(void)
532532
{
533+
int rc;
534+
533535
if (!xen_domain())
534536
return -ENODEV;
535537

536538
pr_info("Initialising Xen transport for 9pfs\n");
537539

538540
v9fs_register_trans(&p9_xen_trans);
539-
return xenbus_register_frontend(&xen_9pfs_front_driver);
541+
rc = xenbus_register_frontend(&xen_9pfs_front_driver);
542+
if (rc)
543+
v9fs_unregister_trans(&p9_xen_trans);
544+
545+
return rc;
540546
}
541547
module_init(p9_trans_xen_init);
542548

0 commit comments

Comments
 (0)