From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751067AbdE3VYm (ORCPT ); Tue, 30 May 2017 17:24:42 -0400 Received: from gateway20.websitewelcome.com ([192.185.50.28]:44336 "EHLO gateway20.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbdE3VYl (ORCPT ); Tue, 30 May 2017 17:24:41 -0400 Date: Tue, 30 May 2017 16:24:36 -0500 From: "Gustavo A. R. Silva" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] mm: add NULL check to avoid potential NULL pointer dereference Message-ID: <20170530212436.GA6195@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.214.95 X-Exim-ID: 1dFod2-000EDX-Nb X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.214.95]:58592 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 2 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org NULL check at line 1226: if (!pgdat), implies that pointer pgdat might be NULL. Function rollback_node_hotadd() dereference this pointer. Add NULL check to avoid a potential NULL pointer dereference. Addresses-Coverity-ID: 1369133 Signed-off-by: Gustavo A. R. Silva --- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 599c675..ea3bc3e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1273,7 +1273,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); -- 2.5.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id 706836B0279 for ; Tue, 30 May 2017 17:24:39 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id l1so105416985oib.4 for ; Tue, 30 May 2017 14:24:39 -0700 (PDT) Received: from gateway31.websitewelcome.com (gateway31.websitewelcome.com. [192.185.143.234]) by mx.google.com with ESMTPS id v40si6043762otd.212.2017.05.30.14.24.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 14:24:38 -0700 (PDT) Received: from cm4.websitewelcome.com (unknown [108.167.139.16]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 0C8F373370 for ; Tue, 30 May 2017 16:24:38 -0500 (CDT) Date: Tue, 30 May 2017 16:24:36 -0500 From: "Gustavo A. R. Silva" Subject: [PATCH] mm: add NULL check to avoid potential NULL pointer dereference Message-ID: <20170530212436.GA6195@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" NULL check at line 1226: if (!pgdat), implies that pointer pgdat might be NULL. Function rollback_node_hotadd() dereference this pointer. Add NULL check to avoid a potential NULL pointer dereference. Addresses-Coverity-ID: 1369133 Signed-off-by: Gustavo A. R. Silva --- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 599c675..ea3bc3e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1273,7 +1273,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); -- 2.5.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org