mm/memory_hotplug.c: add NULL check to avoid potential NULL pointer dereference
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Mon, 10 Jul 2017 22:47:23 +0000 (15:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 10 Jul 2017 23:32:30 +0000 (16:32 -0700)
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 <garsilva@embeddedor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory_hotplug.c

index f79aac7a12b5c4109875439f527aca016f9411a2..7b1311ac5f7ba86f22e5f80d4b231e042271bfd7 100644 (file)
@@ -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);