[dpdk-dev] [PATCH] memzone: Check socket_id value when creating memzone.

nickcooper-zhangtonghao nic at opencloud.tech
Thu Jun 1 03:24:48 CEST 2017


If that patch is ok, will we apply it to master?
Thanks.
Nick

> On May 12, 2017, at 4:42 PM, Bruce Richardson <bruce.richardson at intel.com> wrote:
> 
> On Thu, May 11, 2017 at 11:03:43PM -0700, Tonghao Zhang wrote:
>> If the socket_id is invalid (e.g. -2, -3), the
>> memzone_reserve_aligned_thread_unsafe should return the
>> EINVAL and not ENOMEM. To avoid it, we should check the
>> socket_id before calling malloc_heap_alloc.
>> 
>> Signed-off-by: Tonghao Zhang <nic at opencloud.tech>
>> ---
>> lib/librte_eal/common/eal_common_memzone.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
>> index 64f4e0a..3026e36 100644
>> --- a/lib/librte_eal/common/eal_common_memzone.c
>> +++ b/lib/librte_eal/common/eal_common_memzone.c
>> @@ -189,7 +189,8 @@
>> 		return NULL;
>> 	}
>> 
>> -	if ((socket_id != SOCKET_ID_ANY) && (socket_id >= RTE_MAX_NUMA_NODES)) {
>> +	if ((socket_id != SOCKET_ID_ANY) &&
>> +	    (socket_id >= RTE_MAX_NUMA_NODES || socket_id < 0)) {
>> 		rte_errno = EINVAL;
>> 		return NULL;
>> 	}
>> -- 
> 
> Looks a sensible thing to do.
> 
> Acked-by: Bruce Richardson <bruce.richardson at intel.com <mailto:bruce.richardson at intel.com>>



More information about the dev mailing list