Skip to contentSkip to conversation

lib/sg_pool,debugobjects: remove unnecessary null check when free the object

PATCH In review zhong jiang 2 participants 3 messages Jul 31, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/sg_pool,debugobjects: remove unnecessary null check when free the object

kmem_cache_destroy/mempool_destroy has taken null check into account. so remove the redundant check.

---
 lib/debugobjects.c | 3 +--
 lib/sg_pool.c      | 7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)
lib/debugobjects.c +1 -2
index 994be48..7a6d80b 100644
@@ -1185,8 +1185,7 @@ void __init debug_objects_mem_init(void)
 
 	if (!obj_cache || debug_objects_replace_static_objects()) {
 		debug_objects_enabled = 0;
-		if (obj_cache)
-			kmem_cache_destroy(obj_cache);
+		kmem_cache_destroy(obj_cache);
 		pr_warn("out of memory.\n");
 	} else
 		debug_objects_selftest();
lib/sg_pool.c +3 -4
index 6dd3061..d1c1e63 100644
@@ -148,10 +148,9 @@ static __init int sg_pool_init(void)
 cleanup_sdb:
 	for (i = 0; i < SG_MEMPOOL_NR; i++) {
 		struct sg_pool *sgp = sg_pools + i;
-		if (sgp->pool)
-			mempool_destroy(sgp->pool);
-		if (sgp->slab)
-			kmem_cache_destroy(sgp->slab);
+
+		mempool_destroy(sgp->pool);
+		kmem_cache_destroy(sgp->slab);
 	}
 
 	return -ENOMEM;
Signature · 1 line
1.7.12.4
#1 lore raw
Quoted 2 lines · zhong jiang

kmem_cache_destroy/mempool_destroy has taken null check into account. so remove the redundant check.

Please split the patch so they can be applied independently by the relevant maintainers.

Thanks,

tglx

#2 lore raw
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines · zhong jiang

kmem_cache_destroy/mempool_destroy has taken null check into account. so remove the redundant check.

Quoted 9 lines

Please split the patch so they can be applied independently by the relevant maintainers.

Thanks,

tglx

.

Ok, will do .

Thanks,
zhong jiang