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
This commit is contained in:
Gleb Chesnokov
2022-08-09 18:56:52 +03:00
parent 4649a6abd4
commit ebae8bd223
3 changed files with 6 additions and 13 deletions

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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;
}