]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: qla2xxx: Unregister resources in the opposite order of the registration order
authorBart Van Assche <bvanassche@acm.org>
Thu, 4 Apr 2019 19:44:47 +0000 (12:44 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 9 Apr 2019 02:16:34 +0000 (22:16 -0400)
Make sure that resources are only unregistered after the users of these
resources have been unregistered. Only unregister the character device if
registration of it succeeded.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_os.c

index ea0b666c3c906a24e3ef452e49bf8b9e90f504a6..b0e5484bf02604e61876d27fdc45faaacd02a01c 100644 (file)
@@ -7407,14 +7407,15 @@ destroy_cache:
 static void __exit
 qla2x00_module_exit(void)
 {
-       unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
        pci_unregister_driver(&qla2xxx_pci_driver);
        qla2x00_release_firmware();
-       kmem_cache_destroy(srb_cachep);
-       qlt_exit();
        kmem_cache_destroy(ctx_cachep);
-       fc_release_transport(qla2xxx_transport_template);
        fc_release_transport(qla2xxx_transport_vport_template);
+       if (apidev_major >= 0)
+               unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
+       fc_release_transport(qla2xxx_transport_template);
+       qlt_exit();
+       kmem_cache_destroy(srb_cachep);
 }
 
 module_init(qla2x00_module_init);