From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 703A11B7D6 for ; Tue, 15 May 2018 15:48:14 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id a67-v6so1152705wmf.3 for ; Tue, 15 May 2018 06:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qaa6/wDaxJLV0x0w0BZ2EJUhynECKZ8xERGdBUgWA0Y=; b=lZj54jOjlhGkEJuhnKIxMmdp7NclsJWCoO4rL20U7UDrdxPjwhDwHya3RjSyuRDquO V2R5wJnXN4wLxJqZ1hgHxLCmqJmf3uZJRiYuvaqPrjUldgMeN1OiNL7iO1VEXOfBO5UX T1KUGqeCRwX1zk6wCgALsN/IrlWTiQZOHE7+0X19VMrIkx+6aEGS9mX4eFj5Rgvhpj2E mgPAuIqcJPRuuB+f7DDT4UPphf+hzZZc+ZF9obJSpTMzj+E/zAFhvvH1WYUuFU5Hfzjf e81caUj9fI7OhTD7XODbUX78Ef7OKytFI+WY0KUpWxWc9auXmGrP2Zf3O2yI1NEF4q8i KfHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qaa6/wDaxJLV0x0w0BZ2EJUhynECKZ8xERGdBUgWA0Y=; b=pkN+JboUkSgGt9/LANhHwjH+JfMcAVDdANQKXRYWAxuG4V59a1QbQLgLVJJGwnXNLA 3YAUSBLC1Cocdji01jbeoasAL2jct80zXm0MGpYjh/sqxaBkCW/PeYsarojeMxhZzBE1 tv3livN9dI5XTDRiTb2cDOAaDJ2rcdOZc1oP0oND5W+3pr8r8Ta+qxT1pnoKViqOruwT y0L19Xx29ujn64Sc8HA8tc5fLjmI3VEEOFfUnNbVnkL4MsPE5Ri3bN/kwhotL5N4X+kF DC5bkK8aVjx3lrwaOlPpuif+70qJbHYVm9LElJ9etshAjQ4jeVVpl3MPevlas4+ryTbG 9VnA== X-Gm-Message-State: ALKqPwdMHQ70y2Ry+1T5zTuGaO5uEfono7TQmeUZuNxpLf0hd+I75b14 TDwzTIKvGbF1OLt0GuHmqUA= X-Google-Smtp-Source: AB8JxZom3gY7Y9uRGeqygLqcT1zFB8ADWiTo/NX1N+wmMAgFMX/ko0zvzMWIlIZP1kzDjRtlzopoGA== X-Received: by 2002:a1c:30ce:: with SMTP id w197-v6mr7320537wmw.22.1526392093036; Tue, 15 May 2018 06:48:13 -0700 (PDT) Received: from localhost (slip139-92-244-193.lon.uk.prserv.net. [139.92.244.193]) by smtp.gmail.com with ESMTPSA id a69-v6sm596086wma.7.2018.05.15.06.48.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 06:48:12 -0700 (PDT) From: luca.boccassi@gmail.com To: Reshma Pattan Cc: David Hunt , dpdk stable Date: Tue, 15 May 2018 14:46:29 +0100 Message-Id: <20180515134731.9337-18-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180515134731.9337-1-luca.boccassi@gmail.com> References: <20180503110612.12146-2-luca.boccassi@gmail.com> <20180515134731.9337-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'test/reorder: fix freeing mbuf twice' has been queued to stable release 18.02.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 May 2018 13:48:14 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/16/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From c0b7ae7bf30be96dbedbb6c63cb69ff4c3c32706 Mon Sep 17 00:00:00 2001 From: Reshma Pattan Date: Fri, 4 May 2018 11:47:06 +0100 Subject: [PATCH] test/reorder: fix freeing mbuf twice [ upstream commit ecd867faa860b41a154b3e24f6ea4536562234ab ] mbufs are being freed twice in error, once in rte_mempool_put_bulk() and then in rte_reorder_free(). Refactor the code so that we use rte_reorder_free() to free mbufs in the reorder buffer, and use rte_pktmbuf_free() to free any unused or drained mbufs. Fixes: d0c9b58d71 ("app/test: new reorder unit test") Signed-off-by: Reshma Pattan Reviewed-by: David Hunt --- test/test/test_reorder.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c index 65e4f38b2..ccee4d086 100644 --- a/test/test/test_reorder.c +++ b/test/test/test_reorder.c @@ -146,11 +146,11 @@ test_reorder_insert(void) b = rte_reorder_create("test_insert", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs); - TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool"); - - for (i = 0; i < num_bufs; i++) + for (i = 0; i < num_bufs; i++) { + bufs[i] = rte_pktmbuf_alloc(p); + TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); bufs[i]->seqn = i; + } /* This should fill up order buffer: * reorder_seq = 0 @@ -165,6 +165,7 @@ test_reorder_insert(void) ret = -1; goto exit; } + bufs[i] = NULL; } /* early packet - should move mbufs to ready buf and move sequence window @@ -179,6 +180,7 @@ test_reorder_insert(void) ret = -1; goto exit; } + bufs[4] = NULL; /* early packet from current sequence window - full ready buffer */ bufs[5]->seqn = 2 * size; @@ -189,6 +191,7 @@ test_reorder_insert(void) ret = -1; goto exit; } + bufs[5] = NULL; /* late packet */ bufs[6]->seqn = 3 * size; @@ -199,11 +202,15 @@ test_reorder_insert(void) ret = -1; goto exit; } + bufs[6] = NULL; ret = 0; exit: - rte_mempool_put_bulk(p, (void *)bufs, num_bufs); rte_reorder_free(b); + for (i = 0; i < num_bufs; i++) { + if (bufs[i] != NULL) + rte_pktmbuf_free(bufs[i]); + } return ret; } @@ -219,6 +226,10 @@ test_reorder_drain(void) int ret = 0; unsigned i, cnt; + /* initialize all robufs to NULL */ + for (i = 0; i < num_bufs; i++) + robufs[i] = NULL; + /* This would create a reorder buffer instance consisting of: * reorder_seq = 0 * ready_buf: RB[size] = {NULL, NULL, NULL, NULL} @@ -227,9 +238,6 @@ test_reorder_drain(void) b = rte_reorder_create("test_drain", rte_socket_id(), size); TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); - ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs); - TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool"); - /* Check no drained packets if reorder is empty */ cnt = rte_reorder_drain(b, robufs, 1); if (cnt != 0) { @@ -239,8 +247,11 @@ test_reorder_drain(void) goto exit; } - for (i = 0; i < num_bufs; i++) + for (i = 0; i < num_bufs; i++) { + bufs[i] = rte_pktmbuf_alloc(p); + TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); bufs[i]->seqn = i; + } /* Insert packet with seqn 1: * reorder_seq = 0 @@ -248,6 +259,7 @@ test_reorder_drain(void) * OB[] = {1, NULL, NULL, NULL} */ rte_reorder_insert(b, bufs[1]); + bufs[1] = NULL; cnt = rte_reorder_drain(b, robufs, 1); if (cnt != 1) { @@ -256,6 +268,8 @@ test_reorder_drain(void) ret = -1; goto exit; } + if (robufs[0] != NULL) + rte_pktmbuf_free(robufs[i]); /* Insert more packets * RB[] = {NULL, NULL, NULL, NULL} @@ -263,18 +277,22 @@ test_reorder_drain(void) */ rte_reorder_insert(b, bufs[2]); rte_reorder_insert(b, bufs[3]); + bufs[2] = NULL; + bufs[3] = NULL; /* Insert more packets * RB[] = {NULL, NULL, NULL, NULL} * OB[] = {NULL, 2, 3, 4} */ rte_reorder_insert(b, bufs[4]); + bufs[4] = NULL; /* Insert more packets * RB[] = {2, 3, 4, NULL} * OB[] = {NULL, NULL, 7, NULL} */ rte_reorder_insert(b, bufs[7]); + bufs[7] = NULL; /* drained expected packets */ cnt = rte_reorder_drain(b, robufs, 4); @@ -284,6 +302,10 @@ test_reorder_drain(void) ret = -1; goto exit; } + for (i = 0; i < 3; i++) { + if (robufs[i] != NULL) + rte_pktmbuf_free(robufs[i]); + } /* * RB[] = {NULL, NULL, NULL, NULL} @@ -298,8 +320,13 @@ test_reorder_drain(void) } ret = 0; exit: - rte_mempool_put_bulk(p, (void *)bufs, num_bufs); rte_reorder_free(b); + for (i = 0; i < num_bufs; i++) { + if (bufs[i] != NULL) + rte_pktmbuf_free(bufs[i]); + if (robufs[i] != NULL) + rte_pktmbuf_free(robufs[i]); + } return ret; } -- 2.14.2