Skip to content

Commit

Permalink
mm/memory_hotplug.c: add NULL check to avoid potential NULL pointer d…
Browse files Browse the repository at this point in the history
…ereference

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>
  • Loading branch information
GustavoARSilva authored and torvalds committed Jul 10, 2017
1 parent 0622622 commit dbac61a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit dbac61a

Please sign in to comment.