From: Gustavo A. R. Silva Date: Mon, 10 Jul 2017 22:47:23 +0000 (-0700) Subject: mm/memory_hotplug.c: add NULL check to avoid potential NULL pointer dereference X-Git-Tag: v4.13-rc1~62^2~110 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=dbac61a3f2afac562efa51b0a196ed71b6b8d109;p=linux.git mm/memory_hotplug.c: add NULL check to avoid potential NULL pointer dereference The 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 Link: http://lkml.kernel.org/r/20170530212436.GA6195@embeddedgus Signed-off-by: Gustavo A. R. Silva Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f79aac7a12b5..7b1311ac5f7b 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1268,7 +1268,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online) error: /* rollback pgdat allocation and others */ - if (new_pgdat) + if (new_pgdat && pgdat) rollback_node_hotadd(nid, pgdat); memblock_remove(start, size);