From patchwork Tue May 4 01:07:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 92725 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 90394A0562; Tue, 4 May 2021 03:07:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A8F64014D; Tue, 4 May 2021 03:07:52 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 68FA240147 for ; Tue, 4 May 2021 03:07:50 +0200 (CEST) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FZ1py02rTz16Nj2; Tue, 4 May 2021 09:05:14 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Tue, 4 May 2021 09:07:46 +0800 From: "Min Hu (Connor)" To: CC: , , Date: Tue, 4 May 2021 09:07:49 +0800 Message-ID: <1620090469-30484-1-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1619083120-57343-1-git-send-email-humin29@huawei.com> References: <1619083120-57343-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2] 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) Acked-by: Erik Gabriel Carrillo --- v2: * use TEST_ASSERT_NOT_NULL check "mz" instead of checking the test_info pointer. --- app/test/test_timer_secondary.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/test/test_timer_secondary.c b/app/test/test_timer_secondary.c index 1e8f1d4..16a9f18 100644 --- a/app/test/test_timer_secondary.c +++ b/app/test/test_timer_secondary.c @@ -125,9 +125,9 @@ test_timer_secondary(void) mz = rte_memzone_reserve(TEST_INFO_MZ_NAME, sizeof(*test_info), SOCKET_ID_ANY, 0); - test_info = mz->addr; - TEST_ASSERT_NOT_NULL(test_info, "Couldn't allocate memory for " + TEST_ASSERT_NOT_NULL(mz, "Couldn't allocate memory for " "test data"); + test_info = mz->addr; test_info->tim_mempool = rte_mempool_create("test_timer_mp", NUM_TIMERS, sizeof(struct rte_timer), 0, 0, @@ -171,9 +171,9 @@ test_timer_secondary(void) int i; mz = rte_memzone_lookup(TEST_INFO_MZ_NAME); - test_info = mz->addr; - TEST_ASSERT_NOT_NULL(test_info, "Couldn't lookup memzone for " + TEST_ASSERT_NOT_NULL(mz, "Couldn't lookup memzone for " "test info"); + test_info = mz->addr; for (i = 0; i < NUM_TIMERS; i++) { rte_mempool_get(test_info->tim_mempool, (void **)&tim);