Message ID | 20180829140404.17281-1-cgxu519@gmx.com (mailing list archive) |
---|---|
State | Deferred |
Headers | show |
Series | [v2] virtio_scsi: remove unnecessary condition check | expand |
On Wed, Aug 29, 2018 at 10:04:04PM +0800, Chengguang Xu wrote: > kmem_cache_destroy()/mempool_destroy() can handle NULL pointer > correctly, so there is no need to check NULL pointer before calling > kmem_cache_destroy()/mempool_destroy(). Meanwhile, because this > is in the error case of init function, also remove unnecessary > NULL assignment. Looks good. Reviewed-by: Greg Edwards <gedwards@ddn.com>
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 1c72db94270e..7574bec59a41 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -1012,14 +1012,8 @@ 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); + kmem_cache_destroy(virtscsi_cmd_cache); return ret; }
kmem_cache_destroy()/mempool_destroy() can handle NULL pointer correctly, so there is no need to check NULL pointer before calling kmem_cache_destroy()/mempool_destroy(). Meanwhile, because this is in the error case of init function, also remove unnecessary NULL assignment. Signed-off-by: Chengguang Xu <cgxu519@gmx.com> --- v1->v2: - Remove unnecessary NULL assignment. drivers/scsi/virtio_scsi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)