Skip to contentSkip to conversation

mm/memory_hotplug.c: add NULL check to avoid potential NULL pointer dereference

PATCH New [email protected] 1 participant 1 message Jul 10, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 5/115 mm/memory_hotplug.c: add NULL check to avoid potential NULL pointer dereference

From: "Gustavo A. R. Silva" <[email protected]>
Subject: mm/memory_hotplug.c: add NULL check to avoid potential NULL pointer dereference

NULL check at line 1226: if (!pgdat), implies that pointer pgdat might be NULL.

rollback_node_hotadd() dereferences this pointer. Add NULL check to avoid a potential NULL pointer dereference.

Addresses-Coverity-ID: 1369133

---

 mm/memory_hotplug.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory_hotplug.c renamed from mm/memory_hotplug.c~mm-add-null-check-to-avoid-potential-null-pointer-dereference +1 -1
diff -puN mm/memory_hotplug.c~mm-add-null-check-to-avoid-potential-null-pointer-dereference mm/memory_hotplug.c
@@ -1268,7 +1268,7 @@ register_fail:
 
 error:
 	/* rollback pgdat allocation and others */
-	if (new_pgdat)
+	if (new_pgdat && pgdat)
 		rollback_node_hotadd(nid, pgdat);
 	memblock_remove(start, size);
 

_