app/test: avoid freeing mbuf twice
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Sat, 25 Jun 2016 16:11:21 +0000 (17:11 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 27 Jun 2016 10:43:49 +0000 (12:43 +0200)
In cryptodev tests, when input and output buffers were the same,
the mbuf was being freed twice, causing refcnt_atomic to be negative.

Fixes: 202d375c60bc ("app/test: add cryptodev unit and performance tests")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
app/test/test_cryptodev.c

index 1a67ffb..67608ff 100644 (file)
@@ -396,10 +396,13 @@ ut_teardown(void)
 
        /*
         * free mbuf - both obuf and ibuf are usually the same,
-        * but rte copes even if we call free twice
+        * so check if they point at the same address is necessary,
+        * to avoid freeing the mbuf twice.
         */
        if (ut_params->obuf) {
                rte_pktmbuf_free(ut_params->obuf);
+               if (ut_params->ibuf == ut_params->obuf)
+                       ut_params->ibuf = 0;
                ut_params->obuf = 0;
        }
        if (ut_params->ibuf) {