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 69C6DA0562; Tue, 4 May 2021 03:08:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C6744014D; Tue, 4 May 2021 03:08:54 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 9599240147 for ; Tue, 4 May 2021 03:08:52 +0200 (CEST) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FZ1pQ3v0XzWfNF; Tue, 4 May 2021 09:04:46 +0800 (CST) Received: from [10.67.103.128] (10.67.103.128) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 4 May 2021 09:08:50 +0800 To: "Carrillo, Erik G" , "dev@dpdk.org" CC: "Yigit, Ferruh" , "rsanford@akamai.com" References: <1619083120-57343-1-git-send-email-humin29@huawei.com> From: "Min Hu (Connor)" Message-ID: <952537a8-d723-adad-4f07-d8bac6ae62e2@huawei.com> Date: Tue, 4 May 2021 09:08:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.128] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Subject: Re: [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" ÔÚ 2021/5/2 4:00, Carrillo, Erik G дµÀ: >> -----Original Message----- >> From: Min Hu (Connor) >> Sent: Thursday, April 22, 2021 4:19 AM >> To: dev@dpdk.org >> Cc: Yigit, Ferruh ; rsanford@akamai.com; Carrillo, >> Erik G >> Subject: [PATCH] test/timer: fix memzone reserve failure check >> >> 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"); > > I think the TEST_ASSERT_NOT_NULL check here should be the area we update -- instead of checking the test_info pointer, we should check "mz", and that will address the issue you have noted. We can then move the "test_info = mz->addr" assignment below the assert. > Agreed, fixed in v2, thanks. >> @@ -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"); > > Same thing here -- we can update the TEST_ASSERT_NOT_NULL call here instead, and move it above the "test_info = mz->addr" assignment. > Fixed in v2, thanks. > Thanks, > Erik > >> -- >> 2.7.4 > > . >