nvme-loop: fix module_init (theoretical) error path
authorSagi Grimberg <sagi@grimberg.me>
Sun, 19 Mar 2017 04:26:28 +0000 (06:26 +0200)
committerJens Axboe <axboe@fb.com>
Tue, 4 Apr 2017 15:48:23 +0000 (09:48 -0600)
if nvmf_register_transport happend to fail, we
need to nvmet_unregister_transport as well.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/target/loop.c

index a74cd11e63c61e3028123c9861bb115e9441a314..c95c13898bcb9bf241aa7bf76c5de43d00076fbd 100644 (file)
@@ -745,7 +745,12 @@ static int __init nvme_loop_init_module(void)
        ret = nvmet_register_transport(&nvme_loop_ops);
        if (ret)
                return ret;
-       return nvmf_register_transport(&nvme_loop_transport);
+
+       ret = nvmf_register_transport(&nvme_loop_transport);
+       if (ret)
+               nvmet_unregister_transport(&nvme_loop_ops);
+
+       return ret;
 }
 
 static void __exit nvme_loop_cleanup_module(void)