Reorder the goto label in init() to make it more clearly, and remove
the useless NULL pointer reassignment.

Signed-off-by: Wanlong Gao <[email protected]>
---
 drivers/scsi/virtio_scsi.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index f679b8c..55dfb06 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -774,32 +774,27 @@ static int __init init(void)
        virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
        if (!virtscsi_cmd_cache) {
                pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
-               goto error;
+               return ret;
        }
 
-
-       virtscsi_cmd_pool =
-               mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
-                                        virtscsi_cmd_cache);
+       virtscsi_cmd_pool = mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
+                                                    virtscsi_cmd_cache);
        if (!virtscsi_cmd_pool) {
                pr_err("mempool_create() for virtscsi_cmd_pool failed\n");
-               goto error;
+               goto out_destroy_cache;
        }
+
        ret = register_virtio_driver(&virtio_scsi_driver);
        if (ret < 0)
-               goto error;
+               goto out_destroy_pool;
 
        return 0;
 
-error:
-       if (virtscsi_cmd_pool) {
-               mempool_destroy(virtscsi_cmd_pool);
-               virtscsi_cmd_pool = NULL;
-       }
-       if (virtscsi_cmd_cache) {
-               kmem_cache_destroy(virtscsi_cmd_cache);
-               virtscsi_cmd_cache = NULL;
-       }
+out_destroy_pool:
+       mempool_destroy(virtscsi_cmd_pool);
+out_destroy_cache:
+       kmem_cache_destroy(virtscsi_cmd_cache);
+
        return ret;
 }
 
-- 
1.8.2.rc2

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to