[API-NEXT,v1,1/4] linux-gen: packet: fix odp_packet_free_multi() with single segment pool

Message ID 1497488406-16652-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Add scalable scheduler for travis CI
Related show

Commit Message

Github ODP bot June 15, 2017, 1 a.m.
From: Matias Elo <matias.elo@nokia.com>


Previously the implementation would use wrong handles and crash if
CONFIG_PACKET_MAX_SEGS was set to one.
https://bugs.linaro.org/show_bug.cgi?id=3013

Signed-off-by: Matias Elo <matias.elo@nokia.com>

Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 50 (nagarahalli:api-next-travis)
 ** https://github.com/Linaro/odp/pull/50
 ** Patch: https://github.com/Linaro/odp/pull/50.patch
 ** Base sha: 4f97e500a097928e308a415c32a88465adc5f5cc
 ** Merge commit sha: 95322c7b65a45928baf62cc6dd993c3a3bcdfe3a
 **/
 platform/linux-generic/odp_packet.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 6799c6ef..01a82854 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -581,11 +581,16 @@  void odp_packet_free(odp_packet_t pkt)
 
 void odp_packet_free_multi(const odp_packet_t pkt[], int num)
 {
+	odp_buffer_t buf[num * CONFIG_PACKET_MAX_SEGS];
+	int i;
+
 	if (CONFIG_PACKET_MAX_SEGS == 1) {
-		buffer_free_multi((const odp_buffer_t * const)pkt, num);
+		for (i = 0; i < num; i++)
+			buf[i] = buffer_handle(packet_hdr(pkt[i]));
+
+		buffer_free_multi(buf, num);
 	} else {
-		odp_buffer_t buf[num * CONFIG_PACKET_MAX_SEGS];
-		int i, j;
+		int j;
 		int bufs = 0;
 
 		for (i = 0; i < num; i++) {