memzone: Check socket_id value when creating memzone.
PATCH 1/1 memzone: Check socket_id value when creating memzone.
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.
--- lib/librte_eal/common/eal_common_memzone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_memzone.c +2 -1
@@ -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 ; }
Signature · 1 line
1.8.3.1
Quoted 16 lines · Tonghao Zhang
If the
socket_idis invalid (e.g. -2, -3), thememzone_reserve_aligned_thread_unsafeshould return the EINVAL and not ENOMEM. To avoid it, we should check thesocket_idbefore callingmalloc_heap_alloc.Signed-off-by Tonghao Zhang <[email protected]>--- lib/librte_eal/common/eal_common_memzone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/librte_eal/common/eal_common_memzone.c +0
-0
lib/librte_eal/common/eal_common_memzone.c line 196
Quoted 9 lines
lib/librte_eal/common/eal_common_memzone.c +2
-1@@ -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.
Quoted 32 lines · Bruce Richardson
Quoted 16 lines · Tonghao Zhang
If the
socket_idis invalid (e.g. -2, -3), thememzone_reserve_aligned_thread_unsafeshould return the EINVAL and not ENOMEM. To avoid it, we should check thesocket_idbefore callingmalloc_heap_alloc.Signed-off-by Tonghao Zhang <[email protected]>---
lib/librte_eal/common/eal_common_memzone.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)lib/librte_eal/common/eal_common_memzone.c +0
-0lib/librte_eal/common/eal_common_memzone.c line 196
Quoted 9 lines
lib/librte_eal/common/eal_common_memzone.c +2
-1@@ -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.
Quoted 1 line
Acked-by Bruce Richardson <[email protected] <mailto:[email protected]>>
Thanks for your review.
If that patch is ok, will we apply it to master?
Thanks.
Nick
Quoted 32 lines · Bruce Richardson
Quoted 16 lines · Tonghao Zhang
If the
socket_idis invalid (e.g. -2, -3), thememzone_reserve_aligned_thread_unsafeshould return the EINVAL and not ENOMEM. To avoid it, we should check thesocket_idbefore callingmalloc_heap_alloc.Signed-off-by Tonghao Zhang <[email protected]>---
lib/librte_eal/common/eal_common_memzone.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)lib/librte_eal/common/eal_common_memzone.c +0
-0lib/librte_eal/common/eal_common_memzone.c line 196
Quoted 9 lines
lib/librte_eal/common/eal_common_memzone.c +2
-1@@ -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 <[email protected] <mailto:[email protected]>>
Thomas Monjalon
Applied12/05/2017 10:42, Bruce Richardson:
Quoted 11 lines · Tonghao Zhang
Quoted 6 lines
If the
socket_idis invalid (e.g. -2, -3), thememzone_reserve_aligned_thread_unsafeshould return the EINVAL and not ENOMEM. To avoid it, we should check thesocket_idbefore callingmalloc_heap_alloc.Signed-off-by Tonghao Zhang <[email protected]>Looks a sensible thing to do.
Acked-by Bruce Richardson <[email protected]>
Applied, thanks