All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] memzone: Check socket_id value when creating memzone.
@ 2017-05-12  6:03 Tonghao Zhang
  2017-05-12  8:42 ` Bruce Richardson
  0 siblings, 1 reply; 5+ messages in thread
From: Tonghao Zhang @ 2017-05-12  6:03 UTC (permalink / raw)
  To: dev; +Cc: Tonghao Zhang

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@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;
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] memzone: Check socket_id value when creating memzone.
  2017-05-12  6:03 [PATCH] memzone: Check socket_id value when creating memzone Tonghao Zhang
@ 2017-05-12  8:42 ` Bruce Richardson
  2017-05-17  0:31   ` nickcooper-zhangtonghao
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bruce Richardson @ 2017-05-12  8:42 UTC (permalink / raw)
  To: Tonghao Zhang; +Cc: dev

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@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@intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] memzone: Check socket_id value when creating memzone.
  2017-05-12  8:42 ` Bruce Richardson
@ 2017-05-17  0:31   ` nickcooper-zhangtonghao
  2017-06-01  1:24   ` nickcooper-zhangtonghao
  2017-06-05 16:24   ` Thomas Monjalon
  2 siblings, 0 replies; 5+ messages in thread
From: nickcooper-zhangtonghao @ 2017-05-17  0:31 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev


> On May 12, 2017, at 4:42 PM, Bruce Richardson <bruce.richardson@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@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@intel.com <mailto:bruce.richardson@intel.com>>


Thanks for your review.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] memzone: Check socket_id value when creating memzone.
  2017-05-12  8:42 ` Bruce Richardson
  2017-05-17  0:31   ` nickcooper-zhangtonghao
@ 2017-06-01  1:24   ` nickcooper-zhangtonghao
  2017-06-05 16:24   ` Thomas Monjalon
  2 siblings, 0 replies; 5+ messages in thread
From: nickcooper-zhangtonghao @ 2017-06-01  1:24 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

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@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@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@intel.com <mailto:bruce.richardson@intel.com>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] memzone: Check socket_id value when creating memzone.
  2017-05-12  8:42 ` Bruce Richardson
  2017-05-17  0:31   ` nickcooper-zhangtonghao
  2017-06-01  1:24   ` nickcooper-zhangtonghao
@ 2017-06-05 16:24   ` Thomas Monjalon
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2017-06-05 16:24 UTC (permalink / raw)
  To: Tonghao Zhang; +Cc: dev, Bruce Richardson

12/05/2017 10:42, Bruce Richardson:
> 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@opencloud.tech>
> 
> Looks a sensible thing to do.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-05 16:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-12  6:03 [PATCH] memzone: Check socket_id value when creating memzone Tonghao Zhang
2017-05-12  8:42 ` Bruce Richardson
2017-05-17  0:31   ` nickcooper-zhangtonghao
2017-06-01  1:24   ` nickcooper-zhangtonghao
2017-06-05 16:24   ` Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.