Skip to content

Commit

Permalink
scsi: virtio_scsi: Remove unnecessary condition check
Browse files Browse the repository at this point in the history
kmem_cache_destroy() and mempool_destroy() both correctly handle null
pointer parameters. There is no need to check if the parameter is null
before calling these functions.

Link: https://lore.kernel.org/r/1594307167-8807-1-git-send-email-xianting_tian@126.com
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Xianting Tian <xianting_tian@126.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Xianting Tian authored and Martin K. Petersen committed Jul 14, 2020
1 parent b92a4a9 commit 92e8d03
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/scsi/virtio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,10 @@ static int __init init(void)
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;
}
mempool_destroy(virtscsi_cmd_pool);
virtscsi_cmd_pool = NULL;
kmem_cache_destroy(virtscsi_cmd_cache);
virtscsi_cmd_cache = NULL;
return ret;
}

Expand Down

0 comments on commit 92e8d03

Please sign in to comment.