DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: "Carrillo, Erik G" <erik.g.carrillo@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"rsanford@akamai.com" <rsanford@akamai.com>
Subject: Re: [dpdk-dev] [PATCH] test/timer: fix memzone reserve failure check
Date: Tue, 4 May 2021 09:08:50 +0800	[thread overview]
Message-ID: <952537a8-d723-adad-4f07-d8bac6ae62e2@huawei.com> (raw)
In-Reply-To: <SA2PR11MB51968E5EBB11483644D0BAD1B95D9@SA2PR11MB5196.namprd11.prod.outlook.com>



在 2021/5/2 4:00, Carrillo, Erik G 写道:
>> -----Original Message-----
>> From: Min Hu (Connor) <humin29@huawei.com>
>> Sent: Thursday, April 22, 2021 4:19 AM
>> To: dev@dpdk.org
>> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; rsanford@akamai.com; Carrillo,
>> Erik G <erik.g.carrillo@intel.com>
>> 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) <humin29@huawei.com>
>> ---
>>   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
> 
> .
> 

  reply	other threads:[~2021-05-04  1:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22  9:18 Min Hu (Connor)
2021-05-01 20:00 ` Carrillo, Erik G
2021-05-04  1:08   ` Min Hu (Connor) [this message]
2021-05-04  1:07 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
2021-05-04  1:18   ` Carrillo, Erik G
2021-05-10 14:13   ` Thomas Monjalon
2021-05-11  0:53     ` Min Hu (Connor)
2021-05-11  0:53 ` [dpdk-dev] [PATCH v3] " Min Hu (Connor)
2021-05-12 14:36   ` Thomas Monjalon
2021-05-13  0:19     ` Min Hu (Connor)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=952537a8-d723-adad-4f07-d8bac6ae62e2@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=erik.g.carrillo@intel.com \
    --cc=ferruh.yigit@intel.com \
    --cc=rsanford@akamai.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).