Skip to contentSkip to conversation

mm/demotion: Fix NULL vs IS_ERR checking in memory_tier_init

PATCH Applied Miaoqian Lin 2 participants 2 messages Nov 10, 2022

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

PATCH 1/1 mm/demotion: Fix NULL vs IS_ERR checking in memory_tier_init

The alloc_memory_type() function return error pointers on error instead of NULL.
Use IS_ERR() to check the return value to fix this.

Fixes 7b88bda3761b ("mm/demotion/dax/kmem: set node's abstract distance to MEMTIER_DEFAULT_DAX_ADISTANCE")
---
 mm/memory-tiers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory-tiers.c +1 -1
index fa8c9d07f9ce..ac0dae9e54bf 100644
@@ -645,7 +645,7 @@ static int __init memory_tier_init(void)
 	 * than default DRAM tier.
 	 */
 	default_dram_type = alloc_memory_type(MEMTIER_ADISTANCE_DRAM);
-	if (!default_dram_type)
+	if (IS_ERR(default_dram_type))
 		panic("%s() failed to allocate default DRAM tier\n", __func__);
 
 	/*
Signature · 1 line
2.37.3.671.ge2130fe6da78.dirty
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

The alloc_memory_type() function return error pointers on error instead of NULL.
Use IS_ERR() to check the return value to fix this.

Fixes 7b88bda3761b ("mm/demotion/dax/kmem: set node's abstract distance to MEMTIER_DEFAULT_DAX_ADISTANCE")

Thanks!

Quoted 17 lines
---
 mm/memory-tiers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory-tiers.c +1 -1
index fa8c9d07f9ce..ac0dae9e54bf 100644
@@ -645,7 +645,7 @@ static int __init memory_tier_init(void)
 	 * than default DRAM tier.
 	 */
 	default_dram_type = alloc_memory_type(MEMTIER_ADISTANCE_DRAM);
-	if (!default_dram_type)
+	if (IS_ERR(default_dram_type))
 		panic("%s() failed to allocate default DRAM tier\n", __func__);
 
 	/*