From ebae8bd2235f6d2a26eb208f76c3e67413bd5bcf Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 9 Aug 2022 18:56:52 +0300 Subject: [PATCH] scst: Remove unnecessary null check kmem_cache_destroy() can handle NULL pointer correctly, so there is no need to check NULL pointer before calling kmem_cache_destroy(). For kernel versions before v4.3 there is a backport of kmem_cache_destroy() that checks for a null pointer. This patch fixes the following checkpatch warnings: WARNING:NEEDLESS_IF: kmem_cache_destroy(NULL) is safe and this check is probably not required --- iscsi-scst/kernel/isert-scst/iser_global.c | 6 ++---- qla2x00t/qla_os.c | 3 +-- scst/src/scst_mem.c | 10 +++------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/iscsi-scst/kernel/isert-scst/iser_global.c b/iscsi-scst/kernel/isert-scst/iser_global.c index f7f7f5400..4718025ee 100644 --- a/iscsi-scst/kernel/isert-scst/iser_global.c +++ b/iscsi-scst/kernel/isert-scst/iser_global.c @@ -170,10 +170,8 @@ void isert_global_cleanup(void) isert_portal_list_release_all(); if (isert_glob.conn_wq) destroy_workqueue(isert_glob.conn_wq); - if (isert_cmnd_cache) - kmem_cache_destroy(isert_cmnd_cache); - if (isert_conn_cache) - kmem_cache_destroy(isert_conn_cache); + kmem_cache_destroy(isert_cmnd_cache); + kmem_cache_destroy(isert_conn_cache); } int isert_get_addr_size(struct sockaddr *sa, size_t *addr_len) diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index 99d75fe54..3b84c23a4 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -4902,8 +4902,7 @@ qla2x00_module_exit(void) pci_unregister_driver(&qla2xxx_pci_driver); qla2x00_release_firmware(); kmem_cache_destroy(srb_cachep); - if (ctx_cachep) - kmem_cache_destroy(ctx_cachep); + kmem_cache_destroy(ctx_cachep); fc_release_transport(qla2xxx_transport_template); fc_release_transport(qla2xxx_transport_vport_template); } diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 5202548f7..a2c10e084 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1456,11 +1456,8 @@ out_del: out_free: for (i = 0; i < pool->max_caches; i++) { - if (pool->caches[i]) { - kmem_cache_destroy(pool->caches[i]); - pool->caches[i] = NULL; - } else - break; + kmem_cache_destroy(pool->caches[i]); + pool->caches[i] = NULL; } goto out; } @@ -1537,8 +1534,7 @@ static void sgv_pool_destroy(struct sgv_pool *pool) cancel_delayed_work_sync(&pool->sgv_purge_work); for (i = 0; i < pool->max_caches; i++) { - if (pool->caches[i]) - kmem_cache_destroy(pool->caches[i]); + kmem_cache_destroy(pool->caches[i]); pool->caches[i] = NULL; }