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 B7371A09E4; Thu, 22 Apr 2021 11:18:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 76097413E6; Thu, 22 Apr 2021 11:18:35 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 5EF274069D for ; Thu, 22 Apr 2021 11:18:32 +0200 (CEST) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FQsG801JjzpZWL; Thu, 22 Apr 2021 17:15:27 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Thu, 22 Apr 2021 17:18:27 +0800 From: "Min Hu (Connor)" To: CC: , , Date: Thu, 22 Apr 2021 17:18:40 +0800 Message-ID: <1619083120-57343-1-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] test/timer: fix memzone reserve failure check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Segmentation fault may occur without checking if memzone reserves succeed or not. This patch fixed it. Fixes: 50247fe03fe0 ("test/timer: exercise new APIs in secondary process") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) --- app/test/test_timer_secondary.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/test/test_timer_secondary.c b/app/test/test_timer_secondary.c index 1e8f1d4..281f5bd 100644 --- a/app/test/test_timer_secondary.c +++ b/app/test/test_timer_secondary.c @@ -125,6 +125,11 @@ test_timer_secondary(void) mz = rte_memzone_reserve(TEST_INFO_MZ_NAME, sizeof(*test_info), SOCKET_ID_ANY, 0); + if (mz == NULL) { + printf("Failed to reserve memzone\n"); + return TEST_SKIPPED; + } + test_info = mz->addr; TEST_ASSERT_NOT_NULL(test_info, "Couldn't allocate memory for " "test data"); @@ -171,6 +176,11 @@ test_timer_secondary(void) int i; mz = rte_memzone_lookup(TEST_INFO_MZ_NAME); + if (mz == NULL) { + printf("Failed to lookup memzone\n"); + return TEST_SKIPPED; + } + test_info = mz->addr; TEST_ASSERT_NOT_NULL(test_info, "Couldn't lookup memzone for " "test info"); -- 2.7.4