if a buffer or packet is freed repeatedly, it will be a disaster.
To avoid this, a checking for buffer status is done before free opertion,
and it will do nothing if buffer allocator is ODP_FREEBUF.

Signed-off-by: Zaibo Xu <[email protected]>
---
 platform/linux-generic/odp_pool.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/platform/linux-generic/odp_pool.c 
b/platform/linux-generic/odp_pool.c
index 84d35bf..f26755d 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -562,10 +562,12 @@ void odp_buffer_free(odp_buffer_t buf)
        odp_buffer_hdr_t *buf_hdr = odp_buf_to_hdr(buf);
        pool_entry_t *pool = odp_buf_to_pool(buf_hdr);
 
-       if (odp_unlikely(pool->s.low_wm_assert))
-               ret_buf(&pool->s, buf_hdr);
-       else
-               ret_local_buf(&pool->s.local_cache[local_id], buf_hdr);
+       if (odp_likely(buf_hdr->allocator != ODP_FREEBUF)) {
+               if (odp_unlikely(pool->s.low_wm_assert))
+                       ret_buf(&pool->s, buf_hdr);
+               else
+                       ret_local_buf(&pool->s.local_cache[local_id], buf_hdr);
+       }
 }
 
 void odp_buffer_free_multi(const odp_buffer_t buf[], int len)
-- 
1.9.1

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to