From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 74F2AA00C3 for ; Tue, 14 Dec 2021 14:30:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 38C094003C; Tue, 14 Dec 2021 14:30:31 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 7FBA54003C; Tue, 14 Dec 2021 14:30:29 +0100 (CET) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JCzkb1fkvz91PJ; Tue, 14 Dec 2021 21:29:43 +0800 (CST) Received: from dggpemm500008.china.huawei.com (7.185.36.136) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 14 Dec 2021 21:30:26 +0800 Received: from localhost (10.174.242.157) by dggpemm500008.china.huawei.com (7.185.36.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 14 Dec 2021 21:30:26 +0800 From: Yunjian Wang To: CC: , , , Yunjian Wang , Subject: [dpdk-dev] [PATCH 1/1] mem: check allocation in dynamic hugepage init Date: Tue, 14 Dec 2021 21:30:25 +0800 Message-ID: <3d5cb5cba8ee4ae1d1de5eba1d009eaffbb49062.1639488393.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.242.157] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500008.china.huawei.com (7.185.36.136) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The function malloc() could return NULL, the return value need to be checked. Fixes: 694161b7e065 ("mem: extract common dynamic memory allocation") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- lib/eal/common/eal_common_dynmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/eal/common/eal_common_dynmem.c b/lib/eal/common/eal_common_dynmem.c index 7c5437ddfa..c1e1889f5c 100644 --- a/lib/eal/common/eal_common_dynmem.c +++ b/lib/eal/common/eal_common_dynmem.c @@ -304,6 +304,10 @@ eal_dynmem_hugepage_init(void) needed = num_pages - num_pages_alloc; pages = malloc(sizeof(*pages) * needed); + if (pages == NULL) { + RTE_LOG(ERR, EAL, "Failed to malloc pages\n"); + return -1; + } /* do not request exact number of pages */ cur_pages = eal_memalloc_alloc_seg_bulk(pages, -- 2.27.0