net/ena: fix freeing memory using correct API
authorJan Medala <jan@semihalf.com>
Thu, 30 Jun 2016 15:04:58 +0000 (17:04 +0200)
committerBruce Richardson <bruce.richardson@intel.com>
Fri, 8 Jul 2016 13:23:01 +0000 (15:23 +0200)
Memory zones should be freed using the proper memzone_free function not
rte_free which is for malloc calls.
After allocating memzone it's required to zeroize memory in it, so do so
before storing the handle for later freeing.

Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")

Signed-off-by: Alexander Matushevsky <matua@amazon.com>
Signed-off-by: Jakub Palider <jpa@semihalf.com>
Signed-off-by: Jan Medala <jan@semihalf.com>
drivers/net/ena/base/ena_plat_dpdk.h

index b1ed80c..87c3bf1 100644 (file)
@@ -62,7 +62,7 @@ typedef uint64_t dma_addr_t;
 #endif
 
 #define ena_atomic32_t rte_atomic32_t
-#define ena_mem_handle_t void *
+#define ena_mem_handle_t const struct rte_memzone *
 
 #define SZ_256 (256U)
 #define SZ_4K (4096U)
@@ -188,13 +188,15 @@ typedef uint64_t dma_addr_t;
                snprintf(z_name, sizeof(z_name),                        \
                                "ena_alloc_%d", ena_alloc_cnt++);       \
                mz = rte_memzone_reserve(z_name, size, SOCKET_ID_ANY, 0); \
+               memset(mz->addr, 0, size);                              \
                virt = mz->addr;                                        \
                phys = mz->phys_addr;                                   \
+               handle = mz;                                            \
        } while (0)
 #define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, handle)        \
                ({ ENA_TOUCH(size); ENA_TOUCH(phys);                    \
                   ENA_TOUCH(dmadev);                                   \
-                  rte_free(virt); })
+                  rte_memzone_free(handle); })
 
 #define ENA_MEM_ALLOC_COHERENT_NODE(dmadev, size, virt, phys, node, dev_node) \
        do {                                                            \