DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] memalloc: fix potential underflow on mem size calculation
@ 2018-05-03 13:03 Anatoly Burakov
  2018-05-14  0:14 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Anatoly Burakov @ 2018-05-03 13:03 UTC (permalink / raw)
  To: dev; +Cc: anatoly.burakov

If total memory is already bigger than max memory, an underflow
will occur on subtraction. Fix it by simply stopping whenever
we already have amount of memory that is bigger than maximum.

Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists")
Cc: anatoly.burakov@intel.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 4c943b0..a1e07d8 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -429,6 +429,9 @@ memseg_primary_init(void)
 				break;
 #endif
 
+			if (total_mem >= max_mem)
+				break;
+
 			max_type_mem = RTE_MIN(max_mem - total_mem,
 				(uint64_t)RTE_MAX_MEM_MB_PER_TYPE << 20);
 			max_segs = RTE_MAX_MEMSEG_PER_TYPE;
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH] memalloc: fix potential underflow on mem size calculation
  2018-05-03 13:03 [dpdk-dev] [PATCH] memalloc: fix potential underflow on mem size calculation Anatoly Burakov
@ 2018-05-14  0:14 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2018-05-14  0:14 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev

03/05/2018 15:03, Anatoly Burakov:
> If total memory is already bigger than max memory, an underflow
> will occur on subtraction. Fix it by simply stopping whenever
> we already have amount of memory that is bigger than maximum.
> 
> Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists")
> Cc: anatoly.burakov@intel.com
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

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

end of thread, other threads:[~2018-05-14  0:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 13:03 [dpdk-dev] [PATCH] memalloc: fix potential underflow on mem size calculation Anatoly Burakov
2018-05-14  0:14 ` Thomas Monjalon

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).